*/ public $items; /** * @param string $code Catalogue code. * @param string $subject Object of the finding. * @param string[] $args Template arguments. * @param string $excerpt Excerpt, cut to the maximum length. * @param array $items Aggregated members. */ public static function make( string $code, string $subject, array $args = array(), string $excerpt = '', array $items = array() ): self { $def = Catalogue::finding( $code ); $f = new self(); $f->control = $def[0]; $f->level = $def[1]; $f->code = $code; $f->subject = $subject; $f->args = array_map( 'strval', array_values( $args ) ); $f->compared = Catalogue::render( $def[2], $f->args ); $f->action = Catalogue::render( $def[3], $f->args ); $f->excerpt = Text::cut( $excerpt, Assumptions::EXCERPTS_TOTAL_MAX_CHARS ); $f->items = $items; return $f; } public function toArray(): array { return array( 'control' => $this->control, 'level' => $this->level, 'code' => $this->code, 'subject' => $this->subject, 'args' => $this->args, 'compared' => $this->compared, 'action' => $this->action, 'excerpt' => $this->excerpt, 'items' => $this->items, ); } public static function fromArray( array $a ): self { $f = new self(); $f->control = (int) $a['control']; $f->level = (string) $a['level']; $f->code = (string) $a['code']; $f->subject = (string) $a['subject']; $f->args = isset( $a['args'] ) ? array_map( 'strval', (array) $a['args'] ) : array(); $f->compared = isset( $a['compared'] ) ? (string) $a['compared'] : ''; $f->action = isset( $a['action'] ) ? (string) $a['action'] : ''; $f->excerpt = isset( $a['excerpt'] ) ? (string) $a['excerpt'] : ''; $f->items = isset( $a['items'] ) ? (array) $a['items'] : array(); return $f; } }