Messages::getMessages()   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
 * Contains a list of messages.
13
 */
14
class Messages extends TdObject
15
{
16
    public const TYPE_NAME = 'messages';
17
18
    /**
19
     * Approximate total count of messages found.
20
     *
21
     * @var int
22
     */
23
    protected int $totalCount;
24
25
    /**
26
     * List of messages; messages may be null.
27
     *
28
     * @var Message[]|null
29
     */
30
    protected ?array $messages;
31
32
    public function __construct(int $totalCount, ?array $messages)
33
    {
34
        $this->totalCount = $totalCount;
35
        $this->messages   = $messages;
36
    }
37
38
    public static function fromArray(array $array): Messages
39
    {
40
        return new static(
41
            $array['total_count'],
42
            (isset($array['messages']) ? array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['messages']) : null),
43
        );
44
    }
45
46
    public function typeSerialize(): array
47
    {
48
        return [
49
            '@type'                                     => static::TYPE_NAME,
50
            'total_count'                               => $this->totalCount,
51
            (isset($this->messages) ? array_map(fn ($x) => $x->typeSerialize(), $this->messages) : null),
0 ignored issues
show
Bug introduced by
It seems like $this->messages can also be of type null; however, parameter $arr1 of array_map() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

51
            (isset($this->messages) ? array_map(fn ($x) => $x->typeSerialize(), /** @scrutinizer ignore-type */ $this->messages) : null),
Loading history...
52
        ];
53
    }
54
55
    public function getTotalCount(): int
56
    {
57
        return $this->totalCount;
58
    }
59
60
    public function getMessages(): ?array
61
    {
62
        return $this->messages;
63
    }
64
}
65