MessageSendingStateFailed   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 getRetryAfter() 0 3 1
A getErrorMessage() 0 3 1
A __construct() 0 8 1
A typeSerialize() 0 8 1
A fromArray() 0 7 1
A getErrorCode() 0 3 1
A getCanRetry() 0 3 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
 * The message failed to be sent.
13
 */
14
class MessageSendingStateFailed extends MessageSendingState
15
{
16
    public const TYPE_NAME = 'messageSendingStateFailed';
17
18
    /**
19
     * An error code; 0 if unknown.
20
     *
21
     * @var int
22
     */
23
    protected int $errorCode;
24
25
    /**
26
     * Error message.
27
     *
28
     * @var string
29
     */
30
    protected string $errorMessage;
31
32
    /**
33
     * True, if the message can be re-sent.
34
     *
35
     * @var bool
36
     */
37
    protected bool $canRetry;
38
39
    /**
40
     * Time left before the message can be re-sent, in seconds. No update is sent when this field changes.
41
     *
42
     * @var float
43
     */
44
    protected float $retryAfter;
45
46
    public function __construct(int $errorCode, string $errorMessage, bool $canRetry, float $retryAfter)
47
    {
48
        parent::__construct();
49
50
        $this->errorCode    = $errorCode;
51
        $this->errorMessage = $errorMessage;
52
        $this->canRetry     = $canRetry;
53
        $this->retryAfter   = $retryAfter;
54
    }
55
56
    public static function fromArray(array $array): MessageSendingStateFailed
57
    {
58
        return new static(
59
            $array['error_code'],
60
            $array['error_message'],
61
            $array['can_retry'],
62
            $array['retry_after'],
63
        );
64
    }
65
66
    public function typeSerialize(): array
67
    {
68
        return [
69
            '@type'         => static::TYPE_NAME,
70
            'error_code'    => $this->errorCode,
71
            'error_message' => $this->errorMessage,
72
            'can_retry'     => $this->canRetry,
73
            'retry_after'   => $this->retryAfter,
74
        ];
75
    }
76
77
    public function getErrorCode(): int
78
    {
79
        return $this->errorCode;
80
    }
81
82
    public function getErrorMessage(): string
83
    {
84
        return $this->errorMessage;
85
    }
86
87
    public function getCanRetry(): bool
88
    {
89
        return $this->canRetry;
90
    }
91
92
    public function getRetryAfter(): float
93
    {
94
        return $this->retryAfter;
95
    }
96
}
97