Passed
Pull Request — master (#13)
by
unknown
02:17
created

CustomerVerificationRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
eloc 13
c 2
b 0
f 1
dl 0
loc 34
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Skrill\Request;
6
7
use Skrill\ValueObject\Email;
8
use Skrill\ValueObject\Customer;
9
use Skrill\ValueObject\DateOfBirth;
10
use Skrill\ValueObject\Address;
11
use Skrill\ValueObject\CustomerId;
12
use Skrill\Request\Traits\GetPayloadTrait;
13
use Skrill\ValueObject\MerchantID;
14
15
/**
16
 * Class CustomerVerificationRequest.
17
 */
18
final class CustomerVerificationRequest
19
{
20
    use GetPayloadTrait;
21
22
    /**
23
     * CustomerVerificationRequest constructor.
24
     * @param Email $email
25
     * @param Customer $customer
26
     * @param DateOfBirth $dateOfBirth
27
     * @param Address $address
28
     * @param MerchantID $merchantId
29
     * @param CustomerId|null $customerId
30
     */
31
    public function __construct(
32
        Email $email,
33
        Customer $customer,
34
        DateOfBirth $dateOfBirth,
35
        Address $address,
36
        MerchantID $merchantId,
37
        CustomerId $customerId = null
38
    )
39
    {
40
        $this->payload = [
41
            'email' => (string)$email,
42
            'firstName' => $customer->getFirstName(),
43
            'lastName' => $customer->getLastName(),
44
            'dateOfBirth' => (string)$dateOfBirth,
45
            'postCode' => $address->getPostCode(),
46
            'country' => $address->getCountry(),
47
            'houseNumber' => $address->getHouseNumber(),
48
            'merchantId' => $merchantId->getValue(),
49
        ];
50
        if ($customerId !== null) {
51
            $this->payload['customerId'] = $customerId;
52
        }
53
    }
54
}
55