PageBlockPhoto::getCaption()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace AurimasNiekis\TdLibSchema;
10
11
/**
12
 * A photo.
13
 */
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)
40
    {
41
        parent::__construct();
42
43
        $this->photo   = $photo;
44
        $this->caption = $caption;
45
        $this->url     = $url;
46
    }
47
48
    public static function fromArray(array $array): PageBlockPhoto
49
    {
50
        return new static(
51
            (isset($array['photo']) ? TdSchemaRegistry::fromArray($array['photo']) : null),
52
            TdSchemaRegistry::fromArray($array['caption']),
53
            $array['url'],
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
73
    {
74
        return $this->caption;
75
    }
76
77
    public function getUrl(): string
78
    {
79
        return $this->url;
80
    }
81
}
82