CheckoutUpdate::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Callback;
6
7
use Kerox\Messenger\Model\Common\Address;
8
9
class CheckoutUpdate
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $payload;
15
16
    /**
17
     * @var \Kerox\Messenger\Model\Common\Address
18
     */
19
    protected $shippingAddress;
20
21
    /**
22
     * CheckoutUpdate constructor.
23
     */
24 1
    public function __construct(string $payload, Address $shippingAddress)
25
    {
26 1
        $this->payload = $payload;
27 1
        $this->shippingAddress = $shippingAddress;
28 1
    }
29
30 1
    public function getPayload(): string
31
    {
32 1
        return $this->payload;
33
    }
34
35 1
    public function getShippingAddress(): Address
36
    {
37 1
        return $this->shippingAddress;
38
    }
39
40
    /**
41
     * @return \Kerox\Messenger\Model\Callback\CheckoutUpdate
42
     */
43 1
    public static function create(array $callbackData): self
44
    {
45 1
        $shippingAddress = Address::fromPayload($callbackData['shipping_address']);
46
47 1
        return new self($callbackData['payload'], $shippingAddress);
48
    }
49
}
50