| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | 684 | public function inflect(string $word) : string |
|
| 39 | { |
||
| 40 | 684 | $lowerWord = strtolower($word); |
|
| 41 | |||
| 42 | 684 | if (isset($this->substitutions[$lowerWord])) { |
|
| 43 | 196 | $firstLetterUppercase = $lowerWord[0] !== $word[0]; |
|
| 44 | |||
| 45 | 196 | $toWord = $this->substitutions[$lowerWord]->getTo()->getWord(); |
|
| 46 | |||
| 47 | 196 | if ($firstLetterUppercase) { |
|
| 48 | 2 | return strtoupper($toWord[0]) . substr($toWord, 1); |
|
| 49 | } |
||
| 50 | |||
| 51 | 194 | return $toWord; |
|
| 52 | } |
||
| 53 | |||
| 54 | 489 | return $word; |
|
| 55 | } |
||
| 57 |