|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace TK\API\ValueObject; |
|
5
|
|
|
|
|
6
|
|
|
use TK\API\Exception\InvalidArgumentException; |
|
7
|
|
|
|
|
8
|
|
|
final class AirScheduleRQ implements ValueObjectInterface |
|
9
|
|
|
{ |
|
10
|
|
|
public const AIRLINE_TURKISH_AIRLINES = 'TK'; |
|
11
|
|
|
public const AIRLINE_ANADOLUJET = 'AJ'; |
|
12
|
|
|
|
|
13
|
|
|
private static $airlineCodeEnum = ['TK', 'AJ']; |
|
14
|
|
|
|
|
15
|
|
|
private $directAndNonStopOnlyInd; |
|
16
|
|
|
private $airlineCode; |
|
17
|
|
|
private $originDestinationInformation; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct( |
|
20
|
|
|
OriginDestinationInformation $originDestinationInformation |
|
21
|
|
|
) { |
|
22
|
|
|
$this->originDestinationInformation = $originDestinationInformation; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function withDirectAndNonStopOnlyInd() : AirScheduleRQ |
|
26
|
|
|
{ |
|
27
|
|
|
$this->directAndNonStopOnlyInd = true; |
|
28
|
|
|
return $this; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function withAirlineCode(string $airlineCode) : AirScheduleRQ |
|
32
|
|
|
{ |
|
33
|
|
|
$this->setAirlineCode($airlineCode); |
|
34
|
|
|
return $this; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
private function setAirlineCode(?string $airlineCode) : void |
|
38
|
|
|
{ |
|
39
|
|
|
if (!\in_array($airlineCode, self::$airlineCodeEnum, true)) { |
|
40
|
|
|
throw new InvalidArgumentException( |
|
41
|
|
|
'Invalid AirlineCode provided. Must be one of these: "TK", "AJ"' |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
$this->airlineCode = $airlineCode; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getValue() : array |
|
48
|
|
|
{ |
|
49
|
|
|
$AirScheduleRQValue = [ |
|
50
|
|
|
'OriginDestinationInformation' => $this->originDestinationInformation->getValue() |
|
51
|
|
|
]; |
|
52
|
|
|
if ($this->airlineCode !== null) { |
|
53
|
|
|
$AirScheduleRQValue['AirlineCode'] = $this->airlineCode; |
|
54
|
|
|
} |
|
55
|
|
|
if ($this->directAndNonStopOnlyInd !== null) { |
|
56
|
|
|
$AirScheduleRQValue['FlightTypePref'] = [ |
|
57
|
|
|
'DirectAndNonStopOnlyInd' => $this->directAndNonStopOnlyInd |
|
58
|
|
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
return $AirScheduleRQValue; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|