InputMessageVoiceNote::getDuration()   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 PHPTdGram\Schema;
10
11
/**
12
 * A voice note message.
13
 */
14
class InputMessageVoiceNote extends InputMessageContent
15
{
16
    public const TYPE_NAME = 'inputMessageVoiceNote';
17
18
    /**
19
     * Voice note to be sent.
20
     */
21
    protected InputFile $voiceNote;
22
23
    /**
24
     * Duration of the voice note, in seconds.
25
     */
26
    protected int $duration;
27
28
    /**
29
     * Waveform representation of the voice note, in 5-bit format.
30
     */
31
    protected string $waveform;
32
33
    /**
34
     * Voice note caption; 0-GetOption("message_caption_length_max") characters.
35
     */
36
    protected FormattedText $caption;
37
38
    public function __construct(InputFile $voiceNote, int $duration, string $waveform, FormattedText $caption)
39
    {
40
        parent::__construct();
41
42
        $this->voiceNote = $voiceNote;
43
        $this->duration  = $duration;
44
        $this->waveform  = $waveform;
45
        $this->caption   = $caption;
46
    }
47
48
    public static function fromArray(array $array): InputMessageVoiceNote
49
    {
50
        return new static(
51
            TdSchemaRegistry::fromArray($array['voice_note']),
52
            $array['duration'],
53
            $array['waveform'],
54
            TdSchemaRegistry::fromArray($array['caption']),
55
        );
56
    }
57
58
    public function typeSerialize(): array
59
    {
60
        return [
61
            '@type'      => static::TYPE_NAME,
62
            'voice_note' => $this->voiceNote->typeSerialize(),
63
            'duration'   => $this->duration,
64
            'waveform'   => $this->waveform,
65
            'caption'    => $this->caption->typeSerialize(),
66
        ];
67
    }
68
69
    public function getVoiceNote(): InputFile
70
    {
71
        return $this->voiceNote;
72
    }
73
74
    public function getDuration(): int
75
    {
76
        return $this->duration;
77
    }
78
79
    public function getWaveform(): string
80
    {
81
        return $this->waveform;
82
    }
83
84
    public function getCaption(): FormattedText
85
    {
86
        return $this->caption;
87
    }
88
}
89