Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class PageBlockAudio extends PageBlock |
||
15 | { |
||
16 | public const TYPE_NAME = 'pageBlockAudio'; |
||
17 | |||
18 | /** |
||
19 | * Audio file; may be null. |
||
20 | * |
||
21 | * @var Audio|null |
||
22 | */ |
||
23 | protected ?Audio $audio; |
||
24 | |||
25 | /** |
||
26 | * Audio file caption. |
||
27 | * |
||
28 | * @var PageBlockCaption |
||
29 | */ |
||
30 | protected PageBlockCaption $caption; |
||
31 | |||
32 | public function __construct(?Audio $audio, PageBlockCaption $caption) |
||
33 | { |
||
34 | parent::__construct(); |
||
35 | |||
36 | $this->audio = $audio; |
||
37 | $this->caption = $caption; |
||
38 | } |
||
39 | |||
40 | public static function fromArray(array $array): PageBlockAudio |
||
41 | { |
||
42 | return new static( |
||
43 | (isset($array['audio']) ? TdSchemaRegistry::fromArray($array['audio']) : null), |
||
44 | TdSchemaRegistry::fromArray($array['caption']), |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | public function typeSerialize(): array |
||
49 | { |
||
50 | return [ |
||
51 | '@type' => static::TYPE_NAME, |
||
52 | 'audio' => (isset($this->audio) ? $this->audio : null), |
||
53 | 'caption' => $this->caption->typeSerialize(), |
||
54 | ]; |
||
55 | } |
||
56 | |||
57 | public function getAudio(): ?Audio |
||
60 | } |
||
61 | |||
62 | public function getCaption(): PageBlockCaption |
||
65 | } |
||
66 | } |
||
67 |