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

FiscalData::getCustomerPhone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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