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

CustomerVerificationRequest::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 15
rs 9.9
cc 2
nc 2
nop 6
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(Email $email, Customer $customer, DateOfBirth $dateOfBirth, Address $address,
32
        MerchantID $merchantId, CustomerId $customerId = null)
33
    {
34
        $this->payload = [
35
            'email' => (string)$email,
36
            'firstName' => $customer->getFirstName(),
37
            'lastName' => $customer->getLastName(),
38
            'dateOfBirth' => (string)$dateOfBirth,
39
            'postCode' => $address->getPostCode(),
40
            'country' => $address->getCountry(),
41
            'houseNumber' => $address->getHouseNumber(),
42
            'merchantId' => $merchantId->getValue(),
43
        ];
44
        if ($customerId !== null) {
45
            $this->payload['customerId'] = $customerId;
46
        }
47
    }
48
}
49