PreCheckout::getCurrency()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Callback;
6
7
use Kerox\Messenger\Model\Callback\Payment\RequestedUserInfo;
8
use Kerox\Messenger\Model\Common\Address;
9
10
class PreCheckout
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $payload;
16
17
    /**
18
     * @var \Kerox\Messenger\Model\Callback\Payment\RequestedUserInfo
19
     */
20
    protected $requestedUserInfo;
21
22
    /**
23
     * @var array
24
     */
25
    protected $amount;
26
27
    /**
28
     * PreCheckout constructor.
29
     */
30 1
    public function __construct(string $payload, RequestedUserInfo $requestedUserInfo, array $amount)
31
    {
32 1
        $this->payload = $payload;
33 1
        $this->requestedUserInfo = $requestedUserInfo;
34 1
        $this->amount = $amount;
35 1
    }
36
37 1
    public function getPayload(): string
38
    {
39 1
        return $this->payload;
40
    }
41
42 1
    public function getRequestedUserInfo(): RequestedUserInfo
43
    {
44 1
        return $this->requestedUserInfo;
45
    }
46
47 1
    public function getShippingAddress(): Address
48
    {
49 1
        return $this->requestedUserInfo->getShippingAddress();
50
    }
51
52 1
    public function getCurrency(): ?string
53
    {
54 1
        return $this->amount['currency'] ?? null;
55
    }
56
57 1
    public function getAmount(): ?string
58
    {
59 1
        return $this->amount['amount'] ?? null;
60
    }
61
62
    /**
63
     * @return \Kerox\Messenger\Model\Callback\PreCheckout
64
     */
65 1
    public static function create(array $callbackData): self
66
    {
67 1
        $requestedUserInfo = RequestedUserInfo::create($callbackData['requested_user_info']);
68
69 1
        return new self($callbackData['payload'], $requestedUserInfo, $callbackData['amount']);
70
    }
71
}
72