Completed
Push — master ( 91cedd...fb54ac )
by mehdi
02:53
created

Leap::hijriLeapYear()   B

Complexity

Conditions 12
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 7.4259
cc 12
eloc 4
nc 2
nop 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace OpenCafe\Tools;
2
3
/**
4
 * @since Aug, 21 2015
5
 */
6
class Leap
7
{
8
9
    /**
10
   * @param integer store year value
11
   */
12
    protected $year;
13
14
    /**
15
   * @param string store type of year value
16
   */
17
    protected $type;
18
19
    /**
20
   * @param boolean store result of leap functions
21
   */
22
    protected $result;
23
24
25
    /**
26
   * @param $year integer
27
   * @since Aug, 21 2015
28
   */
29
    public function __construct($year, $type = 'gregorian')
30
    {
31
32
         $this->year = $year;
33
34
         $this->type = $type;
35
36
         return $this;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
37
38
    }
39
40
41
    /**
42
   * return the year is leap or not
43
   *
44
   * @since  Aug, 21 2015
45
   * @return boolean
46
   */
47
    public function get()
48
    {
49
50
      $this->result = include('CalendarSettings/' . ucfirst($this->type) . '.php');
51
52
      return $this->result['leap_year']($this->year);
53
54
    }
55
}
56