MessagePaymentSuccessful::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 7
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 payment has been completed.
13
 */
14
class MessagePaymentSuccessful extends MessageContent
15
{
16
    public const TYPE_NAME = 'messagePaymentSuccessful';
17
18
    /**
19
     * Identifier of the message with the corresponding invoice; can be an identifier of a deleted message.
20
     */
21
    protected int $invoiceMessageId;
22
23
    /**
24
     * Currency for the price of the product.
25
     */
26
    protected string $currency;
27
28
    /**
29
     * Total price for the product, in the minimal quantity of the currency.
30
     */
31
    protected int $totalAmount;
32
33
    public function __construct(int $invoiceMessageId, string $currency, int $totalAmount)
34
    {
35
        parent::__construct();
36
37
        $this->invoiceMessageId = $invoiceMessageId;
38
        $this->currency         = $currency;
39
        $this->totalAmount      = $totalAmount;
40
    }
41
42
    public static function fromArray(array $array): MessagePaymentSuccessful
43
    {
44
        return new static(
45
            $array['invoice_message_id'],
46
            $array['currency'],
47
            $array['total_amount'],
48
        );
49
    }
50
51
    public function typeSerialize(): array
52
    {
53
        return [
54
            '@type'              => static::TYPE_NAME,
55
            'invoice_message_id' => $this->invoiceMessageId,
56
            'currency'           => $this->currency,
57
            'total_amount'       => $this->totalAmount,
58
        ];
59
    }
60
61
    public function getInvoiceMessageId(): int
62
    {
63
        return $this->invoiceMessageId;
64
    }
65
66
    public function getCurrency(): string
67
    {
68
        return $this->currency;
69
    }
70
71
    public function getTotalAmount(): int
72
    {
73
        return $this->totalAmount;
74
    }
75
}
76