| Conditions | 16 | 
| Paths | 512 | 
| Total Lines | 53 | 
| Code Lines | 36 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 17 | public static function createFromArray(array $parameters) : CalculateAwardMilesWithTaxParameters  | 
            ||
| 18 |     { | 
            ||
| 19 | $calculateAwardMilesWithTaxParameters = new CalculateAwardMilesWithTaxParameters(  | 
            ||
| 20 | $parameters['awardType']  | 
            ||
| 21 | );  | 
            ||
| 22 |         if (array_key_exists('wantMoreMiles', $parameters) && $parameters['wantMoreMiles'] === 'T') { | 
            ||
| 23 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters->withSeatGuaranteed();  | 
            ||
| 24 | }  | 
            ||
| 25 |         if (array_key_exists('isOneWay', $parameters) && $parameters['isOneWay'] === 'T') { | 
            ||
| 26 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters->withOneWay();  | 
            ||
| 27 | }  | 
            ||
| 28 |         if (array_key_exists('departureOrigin', $parameters)) { | 
            ||
| 29 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters  | 
            ||
| 30 | ->withDepartureOrigin($parameters['departureOrigin']);  | 
            ||
| 31 | }  | 
            ||
| 32 |         if (array_key_exists('departureDestination', $parameters)) { | 
            ||
| 33 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters  | 
            ||
| 34 | ->withDepartureDestination($parameters['departureDestination']);  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 |         if (array_key_exists('departureDateDay', $parameters) && | 
            ||
| 38 |             array_key_exists('departureDateMonth', $parameters) && | 
            ||
| 39 |             array_key_exists('departureDateYear', $parameters) | 
            ||
| 40 |         ) { | 
            ||
| 41 | $departureDate = $parameters['departureDateYear'] . '-' . $parameters['departureDateMonth'] .  | 
            ||
| 42 | '-' . $parameters['departureDateDay'];  | 
            ||
| 43 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters  | 
            ||
| 44 |                 ->withDepartureDate(DateTimeImmutable::createFromFormat('Y-m-d', $departureDate)); | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 45 | }  | 
            ||
| 46 | |||
| 47 |         if (array_key_exists('arrivalOrigin', $parameters)) { | 
            ||
| 48 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters  | 
            ||
| 49 | ->withArrivalOrigin($parameters['arrivalOrigin']);  | 
            ||
| 50 | }  | 
            ||
| 51 |         if (array_key_exists('arrivalDestination', $parameters)) { | 
            ||
| 52 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters  | 
            ||
| 53 | ->withArrivalDestination($parameters['arrivalDestination']);  | 
            ||
| 54 | }  | 
            ||
| 55 | |||
| 56 |         if (array_key_exists('arrivalDateDay', $parameters) && | 
            ||
| 57 |             array_key_exists('arrivalDateMonth', $parameters) && | 
            ||
| 58 |             array_key_exists('arrivalDateYear', $parameters) | 
            ||
| 59 |         ) { | 
            ||
| 60 | $arrivalDate = $parameters['arrivalDateYear'] . '-' . $parameters['arrivalDateMonth'] .  | 
            ||
| 61 | '-' . $parameters['arrivalDateDay'];  | 
            ||
| 62 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters  | 
            ||
| 63 |                 ->withArrivalDate(DateTimeImmutable::createFromFormat('Y-m-d', $arrivalDate)); | 
            ||
| 64 | }  | 
            ||
| 65 |         if (array_key_exists('ptcType', $parameters)) { | 
            ||
| 66 | $calculateAwardMilesWithTaxParameters = $calculateAwardMilesWithTaxParameters  | 
            ||
| 67 | ->withPassengerType($parameters['ptcType']);  | 
            ||
| 68 | }  | 
            ||
| 69 | return $calculateAwardMilesWithTaxParameters;  | 
            ||
| 70 | }  | 
            ||
| 89 |