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

TimeSpeller   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A spellUnit() 0 8 2
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