Completed
Pull Request — master (#1)
by Romain
02:17
created

FlightSchedule::setBoardingTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
namespace Kerox\Messenger\Model\Message\Attachment\Template\Airline;
3
4
use Kerox\Messenger\ValidatorTrait;
5
6
class FlightSchedule implements \JsonSerializable
7
{
8
9
    use ValidatorTrait;
10
11
    /**
12
     * @var null|string
13
     */
14
    protected $boardingTime;
15
16
    /**
17
     * @var string
18
     */
19
    protected $departureTime;
20
21
    /**
22
     * @var null|string
23
     */
24
    protected $arrivalTime;
25
26
    /**
27
     * FlightSchedule constructor.
28
     *
29
     * @param string $departureTime
30
     */
31
    public function __construct(string $departureTime)
32
    {
33
        $this->isValidDateTime($departureTime);
34
        $this->departureTime = $departureTime;
35
    }
36
37
    /**
38
     * @param string $boardingTime
39
     * @return FlightSchedule
40
     */
41
    public function setBoardingTime(string $boardingTime): FlightSchedule
42
    {
43
        $this->isValidDateTime($boardingTime);
44
        $this->boardingTime = $boardingTime;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @param string $arrivalTime
51
     * @return FlightSchedule
52
     */
53
    public function setArrivalTime(string $arrivalTime): FlightSchedule
54
    {
55
        $this->isValidDateTime($arrivalTime);
56
        $this->arrivalTime = $arrivalTime;
57
58
        return $this;
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function jsonSerialize(): array
65
    {
66
        $json = [
67
            'boarding_time' => $this->boardingTime,
68
            'departure_time' => $this->departureTime,
69
            'arrival_time' => $this->arrivalTime,
70
        ];
71
72
        return array_filter($json);
73
    }
74
}
75