Passed
Push — master ( 2cdaae...14b6d5 )
by Jhao
02:25
created

FiscalData   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 14
c 1
b 0
f 0
dl 0
loc 43
ccs 0
cts 33
cp 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getCustomerName() 0 3 1
A getCustomerEmail() 0 3 1
A getCustomerInn() 0 3 1
A getPrepaidAmount() 0 3 1
A __construct() 0 8 2
A getCustomerPhone() 0 3 1
A toArray() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of RussianPost SDK package.
5
 *
6
 * © Appwilio (http://appwilio.com), greabock (https://github.com/greabock), JhaoDa (https://github.com/jhaoda)
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Orders\Entites;
15
16
use Appwilio\RussianPostSDK\Dispatching\DataAware;
17
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable;
18
19
final class FiscalData implements Arrayable
20
{
21
    use DataAware;
22
23
    public function __construct(?string $email, ?string $phone, ?string $name, ?string $inn, ?int $prepaid)
24
    {
25
        $this->data = [
26
            'customer-email' => $email,
27
            'customer-inn' => $inn,
28
            'customer-name' => $name,
29
            'customer-phone' => $phone ? (int) \preg_replace('~\D+~', '', $phone) : null,
30
            'payment-amount' => $prepaid,
31
        ];
32
    }
33
34
    public function getCustomerEmail(): ?string
35
    {
36
        return $this->get('customer-email');
37
    }
38
39
    public function getCustomerInn(): ?string
40
    {
41
        return $this->get('customer-inn');
42
    }
43
44
    public function getCustomerName(): ?string
45
    {
46
        return $this->get('customer-name');
47
    }
48
49
    public function getCustomerPhone(): ?string
50
    {
51
        return $this->get('customer-phone', 'string');
52
    }
53
54
    public function getPrepaidAmount(): ?int
55
    {
56
        return $this->get('payment-amount');
57
    }
58
59
    public function toArray(): array
60
    {
61
        return $this->data;
62
    }
63
}
64