NetworkStatisticsEntryCall   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 81
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getSentBytes() 0 3 1
A fromArray() 0 7 1
A __construct() 0 8 1
A getReceivedBytes() 0 3 1
A getNetworkType() 0 3 1
A getDuration() 0 3 1
A typeSerialize() 0 8 1
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
 * Contains information about the total amount of data that was used for calls.
13
 */
14
class NetworkStatisticsEntryCall extends NetworkStatisticsEntry
15
{
16
    public const TYPE_NAME = 'networkStatisticsEntryCall';
17
18
    /**
19
     * Type of the network the data was sent through. Call setNetworkType to maintain the actual network type.
20
     *
21
     * @var NetworkType
22
     */
23
    protected NetworkType $networkType;
24
25
    /**
26
     * Total number of bytes sent.
27
     *
28
     * @var int
29
     */
30
    protected int $sentBytes;
31
32
    /**
33
     * Total number of bytes received.
34
     *
35
     * @var int
36
     */
37
    protected int $receivedBytes;
38
39
    /**
40
     * Total call duration, in seconds.
41
     *
42
     * @var float
43
     */
44
    protected float $duration;
45
46
    public function __construct(NetworkType $networkType, int $sentBytes, int $receivedBytes, float $duration)
47
    {
48
        parent::__construct();
49
50
        $this->networkType   = $networkType;
51
        $this->sentBytes     = $sentBytes;
52
        $this->receivedBytes = $receivedBytes;
53
        $this->duration      = $duration;
54
    }
55
56
    public static function fromArray(array $array): NetworkStatisticsEntryCall
57
    {
58
        return new static(
59
            TdSchemaRegistry::fromArray($array['network_type']),
60
            $array['sent_bytes'],
61
            $array['received_bytes'],
62
            $array['duration'],
63
        );
64
    }
65
66
    public function typeSerialize(): array
67
    {
68
        return [
69
            '@type'          => static::TYPE_NAME,
70
            'network_type'   => $this->networkType->typeSerialize(),
71
            'sent_bytes'     => $this->sentBytes,
72
            'received_bytes' => $this->receivedBytes,
73
            'duration'       => $this->duration,
74
        ];
75
    }
76
77
    public function getNetworkType(): NetworkType
78
    {
79
        return $this->networkType;
80
    }
81
82
    public function getSentBytes(): int
83
    {
84
        return $this->sentBytes;
85
    }
86
87
    public function getReceivedBytes(): int
88
    {
89
        return $this->receivedBytes;
90
    }
91
92
    public function getDuration(): float
93
    {
94
        return $this->duration;
95
    }
96
}
97