| Conditions | 10 |
| Paths | 36 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 10 |
| 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 |
||
| 35 | 31 | public function progress(bool $blank = false) { |
|
| 36 | 31 | if ($blank) $teams = $this->from->isPlayed() ? $this->from->sortTeams(null, $this->filters) : $this->from->simulate($this->filters); |
|
| 37 | 14 | else $teams = $this->from->sortTeams(null, $this->filters); |
|
| 38 | |||
| 39 | 31 | if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
|
| 40 | 4 | else $next = $teams; |
|
| 41 | |||
| 42 | 31 | $i = 1; |
|
| 43 | |||
| 44 | 31 | foreach ($next as $team) { |
|
| 45 | 31 | if ($blank) { |
|
| 46 | 17 | $this->to->addTeam(new BlankTeam($this.' - '.$i, $team)); |
|
| 47 | 17 | $i++; |
|
| 48 | } |
||
| 49 | 31 | else $team->sumPoints += $this->from->progressPoints; |
|
| 50 | } |
||
| 51 | |||
| 52 | 31 | $this->from->addProgressed($next); |
|
| 53 | 31 | if (!$blank) $this->to->addTeam($next); |
|
| 54 | 31 | return $this; |
|
| 55 | } |
||
| 58 |