Total Complexity | 8 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class PageBlockPhoto extends PageBlock |
||
15 | { |
||
16 | public const TYPE_NAME = 'pageBlockPhoto'; |
||
17 | |||
18 | /** |
||
19 | * Photo file; may be null. |
||
20 | * |
||
21 | * @var Photo|null |
||
22 | */ |
||
23 | protected ?Photo $photo; |
||
24 | |||
25 | /** |
||
26 | * Photo caption. |
||
27 | * |
||
28 | * @var PageBlockCaption |
||
29 | */ |
||
30 | protected PageBlockCaption $caption; |
||
31 | |||
32 | /** |
||
33 | * URL that needs to be opened when the photo is clicked. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected string $url; |
||
38 | |||
39 | public function __construct(?Photo $photo, PageBlockCaption $caption, string $url) |
||
46 | } |
||
47 | |||
48 | public static function fromArray(array $array): PageBlockPhoto |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | public function typeSerialize(): array |
||
58 | { |
||
59 | return [ |
||
60 | '@type' => static::TYPE_NAME, |
||
61 | 'photo' => (isset($this->photo) ? $this->photo : null), |
||
62 | 'caption' => $this->caption->typeSerialize(), |
||
63 | 'url' => $this->url, |
||
64 | ]; |
||
65 | } |
||
66 | |||
67 | public function getPhoto(): ?Photo |
||
68 | { |
||
69 | return $this->photo; |
||
70 | } |
||
71 | |||
72 | public function getCaption(): PageBlockCaption |
||
75 | } |
||
76 | |||
77 | public function getUrl(): string |
||
80 | } |
||
81 | } |
||
82 |