Total Complexity | 6 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class PageBlockDetails extends PageBlock |
||
15 | { |
||
16 | public const TYPE_NAME = 'pageBlockDetails'; |
||
17 | |||
18 | /** |
||
19 | * Always visible heading for the block. |
||
20 | */ |
||
21 | protected RichText $header; |
||
22 | |||
23 | /** |
||
24 | * Block contents. |
||
25 | * |
||
26 | * @var PageBlock[] |
||
27 | */ |
||
28 | protected array $pageBlocks; |
||
29 | |||
30 | /** |
||
31 | * True, if the block is open by default. |
||
32 | */ |
||
33 | protected bool $isOpen; |
||
34 | |||
35 | public function __construct(RichText $header, array $pageBlocks, bool $isOpen) |
||
36 | { |
||
37 | parent::__construct(); |
||
38 | |||
39 | $this->header = $header; |
||
40 | $this->pageBlocks = $pageBlocks; |
||
41 | $this->isOpen = $isOpen; |
||
42 | } |
||
43 | |||
44 | public static function fromArray(array $array): PageBlockDetails |
||
45 | { |
||
46 | return new static( |
||
47 | TdSchemaRegistry::fromArray($array['header']), |
||
48 | array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['pageBlocks']), |
||
49 | $array['is_open'], |
||
50 | ); |
||
51 | } |
||
52 | |||
53 | public function typeSerialize(): array |
||
54 | { |
||
55 | return [ |
||
56 | '@type' => static::TYPE_NAME, |
||
57 | 'header' => $this->header->typeSerialize(), |
||
58 | array_map(fn ($x) => $x->typeSerialize(), $this->pageBlocks), |
||
59 | 'is_open' => $this->isOpen, |
||
60 | ]; |
||
61 | } |
||
62 | |||
63 | public function getHeader(): RichText |
||
66 | } |
||
67 | |||
68 | public function getPageBlocks(): array |
||
69 | { |
||
70 | return $this->pageBlocks; |
||
71 | } |
||
72 | |||
73 | public function getIsOpen(): bool |
||
76 | } |
||
77 | } |
||
78 |