InputMessageLocation::getLivePeriod()   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 message with a location.
13
 */
14
class InputMessageLocation extends InputMessageContent
15
{
16
    public const TYPE_NAME = 'inputMessageLocation';
17
18
    /**
19
     * Location to be sent.
20
     */
21
    protected Location $location;
22
23
    /**
24
     * Period for which the location can be updated, in seconds; should be between 60 and 86400 for a live location and 0 otherwise.
25
     */
26
    protected int $livePeriod;
27
28
    public function __construct(Location $location, int $livePeriod)
29
    {
30
        parent::__construct();
31
32
        $this->location   = $location;
33
        $this->livePeriod = $livePeriod;
34
    }
35
36
    public static function fromArray(array $array): InputMessageLocation
37
    {
38
        return new static(
39
            TdSchemaRegistry::fromArray($array['location']),
40
            $array['live_period'],
41
        );
42
    }
43
44
    public function typeSerialize(): array
45
    {
46
        return [
47
            '@type'       => static::TYPE_NAME,
48
            'location'    => $this->location->typeSerialize(),
49
            'live_period' => $this->livePeriod,
50
        ];
51
    }
52
53
    public function getLocation(): Location
54
    {
55
        return $this->location;
56
    }
57
58
    public function getLivePeriod(): int
59
    {
60
        return $this->livePeriod;
61
    }
62
}
63