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