Complex classes like FlightValidator often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FlightValidator, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 11 | class FlightValidator extends AbstractValidator  | 
            ||
| 12 | { | 
            ||
| 13 | /**  | 
            ||
| 14 | * @var Product  | 
            ||
| 15 | */  | 
            ||
| 16 | private $defaultService;  | 
            ||
| 17 | |||
| 18 | /**  | 
            ||
| 19 | * @inheritDoc  | 
            ||
| 20 | */  | 
            ||
| 21 | public function __construct(Translate $langs, DoliDB $db, $defaultServiceId)  | 
            ||
| 26 | |||
| 27 | /**  | 
            ||
| 28 |      * {@inheritdoc} | 
            ||
| 29 | */  | 
            ||
| 30 | public function isValid($flight, $context = [])  | 
            ||
| 49 | |||
| 50 | /**  | 
            ||
| 51 | * @param array $context  | 
            ||
| 52 | *  | 
            ||
| 53 | * @return bool  | 
            ||
| 54 | */  | 
            ||
| 55 | private function isGroupedFlight($context)  | 
            ||
| 59 | |||
| 60 | /**  | 
            ||
| 61 | * @param string $hour  | 
            ||
| 62 | *  | 
            ||
| 63 | * @return bool  | 
            ||
| 64 | */  | 
            ||
| 65 | private function isHourValid($hour)  | 
            ||
| 70 | |||
| 71 | /**  | 
            ||
| 72 | * @param $defaultServiceId  | 
            ||
| 73 | */  | 
            ||
| 74 | private function fetchService($defaultServiceId)  | 
            ||
| 79 | |||
| 80 | /**  | 
            ||
| 81 | * Returns the minimum price.  | 
            ||
| 82 | *  | 
            ||
| 83 | * @return int  | 
            ||
| 84 | */  | 
            ||
| 85 | private function getMinPrice()  | 
            ||
| 92 | |||
| 93 | /**  | 
            ||
| 94 | * @param Bbcvols $vol  | 
            ||
| 95 | * @param array $context  | 
            ||
| 96 | *  | 
            ||
| 97 | * @return $this  | 
            ||
| 98 | */  | 
            ||
| 99 | private function checkBillingInformation($vol, $context)  | 
            ||
| 122 | |||
| 123 | /**  | 
            ||
| 124 | * @param Bbcvols $vol  | 
            ||
| 125 | * @param array $context  | 
            ||
| 126 | *  | 
            ||
| 127 | * @return $this  | 
            ||
| 128 | */  | 
            ||
| 129 | private function checkInstructionInformation($vol, $context)  | 
            ||
| 144 | |||
| 145 | /**  | 
            ||
| 146 | * @param Bbcvols $vol  | 
            ||
| 147 | *  | 
            ||
| 148 | * @return $this  | 
            ||
| 149 | */  | 
            ||
| 150 | private function checkPassengersInformation($vol)  | 
            ||
| 176 | |||
| 177 | /**  | 
            ||
| 178 | * @param Bbcvols $vol  | 
            ||
| 179 | *  | 
            ||
| 180 | * @return $this  | 
            ||
| 181 | */  | 
            ||
| 182 | private function checkKilometers($vol)  | 
            ||
| 196 | |||
| 197 | /**  | 
            ||
| 198 | * @param Bbcvols $vol  | 
            ||
| 199 | *  | 
            ||
| 200 | * @return $this  | 
            ||
| 201 | */  | 
            ||
| 202 | private function checkFlightInformation($vol)  | 
            ||
| 226 | |||
| 227 | /**  | 
            ||
| 228 | * @param Bbcvols $vol  | 
            ||
| 229 | *  | 
            ||
| 230 | * @return $this  | 
            ||
| 231 | */  | 
            ||
| 232 | private function checkOrderInformation(Bbcvols $vol)  | 
            ||
| 253 | |||
| 254 | /**  | 
            ||
| 255 | * @param Bbcvols $flight  | 
            ||
| 256 | *  | 
            ||
| 257 | * @return $this  | 
            ||
| 258 | */  | 
            ||
| 259 | private function checkFlightDate(Bbcvols $flight)  | 
            ||
| 267 | }  |