| Conditions | 10 |
| Paths | 512 |
| Total Lines | 37 |
| Code Lines | 25 |
| 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 |
||
| 109 | public function getValue() : array |
||
| 110 | { |
||
| 111 | $calculateAwardMilesWithTaxParameters = [ |
||
| 112 | 'awardType' => $this->awardType |
||
| 113 | ]; |
||
| 114 | if ($this->wantMoreMiles !== null) { |
||
| 115 | $calculateAwardMilesWithTaxParameters['wantMoreMiles'] = 'T'; |
||
| 116 | } |
||
| 117 | if ($this->isOneWay !== null) { |
||
| 118 | $calculateAwardMilesWithTaxParameters['isOneWay'] = 'T'; |
||
| 119 | } |
||
| 120 | if ($this->departureOrigin !== null) { |
||
| 121 | $calculateAwardMilesWithTaxParameters['departureOrigin'] = $this->departureOrigin; |
||
| 122 | } |
||
| 123 | if ($this->departureDestination !== null) { |
||
| 124 | $calculateAwardMilesWithTaxParameters['departureDestination'] = $this->departureDestination; |
||
| 125 | } |
||
| 126 | if ($this->departureDate !== null) { |
||
| 127 | $calculateAwardMilesWithTaxParameters['departureDateDay'] = (int) $this->departureDate->format('j'); |
||
| 128 | $calculateAwardMilesWithTaxParameters['departureDateMonth'] = (int) $this->departureDate->format('n'); |
||
| 129 | $calculateAwardMilesWithTaxParameters['departureDateYear'] = (int) $this->departureDate->format('Y'); |
||
| 130 | } |
||
| 131 | if ($this->arrivalOrigin !== null) { |
||
| 132 | $calculateAwardMilesWithTaxParameters['arrivalOrigin'] = $this->arrivalOrigin; |
||
| 133 | } |
||
| 134 | if ($this->arrivalDestination !== null) { |
||
| 135 | $calculateAwardMilesWithTaxParameters['arrivalDestination'] = $this->arrivalDestination; |
||
| 136 | } |
||
| 137 | if ($this->arrivalDate !== null) { |
||
| 138 | $calculateAwardMilesWithTaxParameters['arrivalDateDay'] = (int) $this->arrivalDate->format('j'); |
||
| 139 | $calculateAwardMilesWithTaxParameters['arrivalDateMonth'] = (int) $this->arrivalDate->format('n'); |
||
| 140 | $calculateAwardMilesWithTaxParameters['arrivalDateYear'] = (int) $this->arrivalDate->format('Y'); |
||
| 141 | } |
||
| 142 | if ($this->ptcType !== null) { |
||
| 143 | $calculateAwardMilesWithTaxParameters['ptcType'] = $this->ptcType; |
||
| 144 | } |
||
| 145 | return $calculateAwardMilesWithTaxParameters; |
||
| 146 | } |
||
| 148 |