MessageAudio::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
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
 * An audio message.
13
 */
14
class MessageAudio extends MessageContent
15
{
16
    public const TYPE_NAME = 'messageAudio';
17
18
    /**
19
     * The audio description.
20
     *
21
     * @var Audio
22
     */
23
    protected Audio $audio;
24
25
    /**
26
     * Audio caption.
27
     *
28
     * @var FormattedText
29
     */
30
    protected FormattedText $caption;
31
32
    public function __construct(Audio $audio, FormattedText $caption)
33
    {
34
        parent::__construct();
35
36
        $this->audio   = $audio;
37
        $this->caption = $caption;
38
    }
39
40
    public static function fromArray(array $array): MessageAudio
41
    {
42
        return new static(
43
            TdSchemaRegistry::fromArray($array['audio']),
44
            TdSchemaRegistry::fromArray($array['caption']),
45
        );
46
    }
47
48
    public function typeSerialize(): array
49
    {
50
        return [
51
            '@type'   => static::TYPE_NAME,
52
            'audio'   => $this->audio->typeSerialize(),
53
            'caption' => $this->caption->typeSerialize(),
54
        ];
55
    }
56
57
    public function getAudio(): Audio
58
    {
59
        return $this->audio;
60
    }
61
62
    public function getCaption(): FormattedText
63
    {
64
        return $this->caption;
65
    }
66
}
67