| Total Complexity | 6 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class GetFareFamilyListParameters implements ValueObjectInterface |
||
| 9 | { |
||
| 10 | private $portList; |
||
| 11 | private $isMilesRequest = 'F'; |
||
| 12 | |||
| 13 | public function __construct() |
||
| 14 | { |
||
| 15 | $this->portList = []; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function withAirportIataCode(string $portIataCode) : GetFareFamilyListParameters |
||
| 19 | { |
||
| 20 | $this->checkPortIataCode($portIataCode); |
||
| 21 | $this->portList[] = $portIataCode; |
||
| 22 | return $this; |
||
| 23 | } |
||
| 24 | |||
| 25 | private function checkPortIataCode(string $portIataCode) : void |
||
| 26 | { |
||
| 27 | if (!preg_match('/^[A-Z]{3}$/', $portIataCode)) { |
||
| 28 | { |
||
| 29 | throw new InvalidArgumentException( |
||
| 30 | 'Invalid portList value provided. Valid IATA code must be used.' |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | public function withMilesRequest() : GetFareFamilyListParameters |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getValue() : array |
||
| 43 | { |
||
| 50 |