Completed
Push — master ( eb575e...c103e9 )
by Romain
13s
created

Airport::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Message\Attachment\Template\Airline;
6
7
class Airport implements \JsonSerializable
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $airportCode;
13
14
    /**
15
     * @var string
16
     */
17
    protected $city;
18
19
    /**
20
     * @var string
21
     */
22
    protected $terminal;
23
24
    /**
25
     * @var string
26
     */
27
    protected $gate;
28
29
    /**
30
     * Airport constructor.
31
     *
32
     * @param string $airportCode
33 10
     * @param string $city
34
     */
35 10
    public function __construct(string $airportCode, string $city)
36 10
    {
37 10
        $this->airportCode = $airportCode;
38
        $this->city = $city;
39
    }
40
41
    /**
42
     * @param string $airportCode
43
     * @param string $city
44 10
     *
45
     * @return \Kerox\Messenger\Model\Message\Attachment\Template\Airline\Airport
46 10
     */
47
    public static function create(string $airportCode, string $city): self
48 10
    {
49
        return new self($airportCode, $city);
50
    }
51
52
    /**
53
     * @param string $terminal
54
     *
55
     * @return Airport
56 10
     */
57
    public function setTerminal(string $terminal): self
58 10
    {
59
        $this->terminal = $terminal;
60 10
61
        return $this;
62
    }
63
64
    /**
65
     * @param string $gate
66 5
     *
67
     * @return Airport
68
     */
69 5
    public function setGate(string $gate): self
70 5
    {
71 5
        $this->gate = $gate;
72 5
73
        return $this;
74
    }
75 5
76
    /**
77
     * @return array
78
     */
79
    public function toArray(): array
80
    {
81
        $array = [
82
            'airport_code' => $this->airportCode,
83
            'city'         => $this->city,
84
            'terminal'     => $this->terminal,
85
            'gate'         => $this->gate,
86
        ];
87
88
        return array_filter($array);
89
    }
90
91
    /**
92
     * @return array
93
     */
94
    public function jsonSerialize(): array
95
    {
96
        return $this->toArray();
97
    }
98
}
99