Lists   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 35 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 28
loc 80
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A years() 0 4 1
A months() 0 4 1
A days() 7 7 1
A hours() 7 7 1
A minutes() 7 7 1
A seconds() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Tuum\Form\Lists;
3
4
class Lists
5
{
6
    /**
7
     * @param int|null $start
8
     * @param int|null $end
9
     * @param int      $step
10
     * @return YearList
11
     */
12
    public static function years($start = null, $end = null, $step = 1)
13
    {
14
        return YearList::forge($start, $end, $step);
15
    }
16
17
    /**
18
     * @param int|null $start
19
     * @param int|null $end
20
     * @param int      $step
21
     * @return MonthList
22
     */
23
    public static function months($start = 1, $end = 12, $step = 1)
24
    {
25
        return MonthList::forge($start, $end, $step);
26
    }
27
28
    /**
29
     * @param int|null $start
30
     * @param int|null $end
31
     * @param int      $step
32
     * @return GenericList
33
     */
34 View Code Duplication
    public static function days($start = 1, $end = 31, $step = 1)
35
    {
36
        return GenericList::forge($start, $end, $step)->setFormat(
37
            function ($day) {
38
                return sprintf('%02d', $day);
39
            });
40
    }
41
42
    /**
43
     * @param int|null $start
44
     * @param int|null $end
45
     * @param int      $step
46
     * @return GenericList
47
     */
48 View Code Duplication
    public static function hours($start = 0, $end = 23, $step = 1)
49
    {
50
        return GenericList::forge($start, $end, $step)->setFormat(
51
            function ($hour) {
52
                return sprintf('%02d', $hour);
53
            });
54
    }
55
56
    /**
57
     * @param int|null $start
58
     * @param int|null $end
59
     * @param int      $step
60
     * @return GenericList
61
     */
62 View Code Duplication
    public static function minutes($start = 0, $end = 59, $step = 5)
63
    {
64
        return GenericList::forge($start, $end, $step)->setFormat(
65
            function ($min) {
66
                return sprintf('%02d', $min);
67
            });
68
    }
69
70
    /**
71
     * @param int|null $start
72
     * @param int|null $end
73
     * @param int      $step
74
     * @return GenericList
75
     */
76 View Code Duplication
    public static function seconds($start = 0, $end = 59, $step = 15)
77
    {
78
        return GenericList::forge($start, $end, $step)->setFormat(
79
            function ($sec) {
80
                return sprintf('%02d', $sec);
81
            });
82
    }
83
}