getOrdinalSuffix()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 12
c 1
b 0
f 0
nc 6
nop 1
dl 0
loc 14
rs 9.2222
1
<?php
2
3
/**
4
 * Returns the ordinal suffix for
5
 * a number from 1 to 5, if the
6
 * param is greater than, or in
7
 * fact is not a number just returns
8
 * the param.
9
 *
10
 * @return string
11
 */
12
function getOrdinalSuffix($number) :string
13
{
14
    switch ($number) {
15
        case 1:
16
            return 'st';
17
        case 2:
18
            return 'nd';
19
        case 3:
20
            return 'rd';
21
        case 4:
22
        case 5:
23
            return 'th';
24
        default:
25
            return $number;
26
    }
27
}
28