Issues (10)

src/Traits/InflectionOrdinalizeTrait.php (1 issue)

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
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

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.

Loading history...
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