1 | <?php |
||
2 | |||
3 | namespace Nip\Inflector\Traits; |
||
4 | |||
5 | /** |
||
6 | * Trait InflectionOrdinalizeTrait |
||
7 | * @package Nip\Inflector\Traits |
||
8 | * |
||
9 | * @method ordinalize($string) |
||
10 | */ |
||
11 | trait InflectionOrdinalizeTrait |
||
12 | { |
||
13 | |||
14 | |||
15 | /** |
||
16 | * @param $number |
||
17 | * @return string |
||
18 | */ |
||
19 | protected function doOrdinalize($number) |
||
20 | { |
||
21 | if (in_array(($number % 100), range(11, 13))) { |
||
22 | return $number . 'th'; |
||
23 | } else { |
||
24 | switch (($number % 10)) { |
||
25 | case 1: |
||
26 | return $number . 'st'; |
||
27 | break; |
||
0 ignored issues
–
show
|
|||
28 | case 2: |
||
29 | return $number . 'nd'; |
||
30 | break; |
||
31 | case 3: |
||
32 | return $number . 'rd'; |
||
33 | default: |
||
34 | return $number . 'th'; |
||
35 | break; |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 |
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.