Completed
Push — master ( f494d8...e90c31 )
by f
01:28
created

TimeSpeller::spellUnit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 8
rs 9.4285
1
<?php
2
namespace morphos\English;
3
4
use InvalidArgumentException;
5
6
class TimeSpeller extends \morphos\TimeSpeller
7
{
8
    protected static $units = [
9
        self::YEAR => 'year',
10
        self::MONTH => 'month',
11
        self::DAY => 'day',
12
        self::HOUR => 'hour',
13
        self::MINUTE => 'minute',
14
        self::SECOND => 'second',
15
    ];
16
17
    public static function spellUnit($count, $unit)
18
    {
19
        if (!isset(self::$units[$unit])) {
20
            throw new InvalidArgumentException('Unknown time unit: '.$unit);
21
        }
22
23
        return $count.' '.NounPluralization::pluralize(self::$units[$unit], $count);
24
    }
25
}
26