Passed
Push — main ( 7189b9...23cbe4 )
by Vasil
03:17
created

ShipmentPhoneNumber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Service\Shipment;
6
7
use VasilDakov\Speedy\Speedy;
8
9
/**
10
 * Class ShipmentPhoneNumber
11
 *
12
 * @author Vasil Dakov <[email protected]>
13
 * @author Valentin Valkanov <[email protected]>
14
 * @copyright 2009-2022 Neutrino.bg
15
 * @version 1.0
16
 * @todo https://api.speedy.bg/web-api.html?fbclid=IwAR1pcF0uXsAZheAKesQcArBJ7QenkDVyEz36aXwfRGCQZvcInjIYMuE82E4#href-ds-shipment-phone-number
17
 */
18
class ShipmentPhoneNumber
19
{
20
    /**
21
     * @var string
22
     */
23
    private string $number;
24
25
    /**
26
     * @var string|null
27
     */
28
    private ?string $extension = null;
29
30
    /**
31
     * @param string $number
32
     */
33 5
    public function __construct(string $number)
34
    {
35 5
        $this->setNumber($number);
36
    }
37
38
    /**
39
     * @param string $number
40
     * @return void
41
     */
42 5
    private function setNumber(string $number): void
43
    {
44 5
        $this->number = $number;
45
    }
46
47
    /**
48
     * @return string number
49
     */
50 4
    public function getNumber(): string
51
    {
52 4
        return $this->number;
53
    }
54
55
    /**
56
     * @param string $extension
57
     * @return self
58
     */
59 1
    public function setExtension(string $extension): self
60
    {
61 1
        $this->extension = $extension;
62
63 1
        return $this;
64
    }
65
66
    /**
67
     * @return string|null
68
     */
69 4
    public function getExtension(): ?string
70
    {
71 4
        return $this->extension;
72
    }
73
74
    /**
75
     * @return array
76
     */
77 3
    public function toArray(): array
78
    {
79 3
        return [
80 3
            Speedy::NUMBER    => $this->getNumber(),
81 3
            Speedy::EXTENSION => $this->getExtension()
82 3
        ];
83
    }
84
}
85