MonthList   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A forge() 0 10 1
A useFullText() 0 4 1
A formatFullText() 0 20 1
1
<?php
2
namespace Tuum\Form\Lists;
3
4
use Closure;
5
6
class MonthList extends AbstractList
7
{
8
    /**
9
     * @param null|int $start
10
     * @param null|int $end
11
     * @param int      $step
12
     * @return MonthList|static
13
     */
14
    public static function forge($start = 1, $end = 12, $step = 1)
15
    {
16
        return new self(
17
            $start,
18
            $end,
19
            $step,
20
            function ($month) {
21
                return sprintf('%2d', $month);
22
            });
23
    }
24
25
    /**
26
     * uses full-text of month name, like 'January'.
27
     *
28
     * @return $this
29
     */
30
    public function useFullText()
31
    {
32
        return $this->setFormat(self::formatFullText());
33
    }
34
35
    /**
36
     * @return Closure
37
     */
38
    public static function formatFullText()
39
    {
40
        return function ($m) {
41
            $list = [
42
                'January',
43
                'February',
44
                'March',
45
                'April',
46
                'May',
47
                'June',
48
                'July',
49
                'August',
50
                'September',
51
                'October',
52
                'November',
53
                'December'
54
            ];
55
            return $list[--$m];
56
        };
57
    }
58
}
59