Passed
Push — master ( 03087a...f49b8e )
by Gabriel
01:58
created

InflectionOrdinalizeTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B doOrdinalize() 0 20 5
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
Unused Code introduced by
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;
0 ignored issues
show
Unused Code introduced by
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...
31
                case 3:
32
                    return $number . 'rd';
33
                default:
34
                    return $number . 'th';
35
                    break;
0 ignored issues
show
Unused Code introduced by
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...
36
            }
37
        }
38
    }
39
}
40