Completed
Push — master ( f6fd8e...15d0ea )
by
unknown
11s
created

DayOf::lastDayMonth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 7
loc 7
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace OpenCafe\Tools;
4
5
/**
6
 * Define Day of current date.
7
 */
8
class DayOf
9
{
10
11
    protected $date_time;
12
13
    protected $month;
14
15
    protected $day;
16
17
    protected $config;
18
19
    protected $result;
20
21
    protected $calendar_type;
22
23
    protected $geregorian_DayofWeek;
24
25
    public function __construct($date_time, $calendar_type = 'gregorian')
26
    {
27
28
        $this->config = include __DIR__.'/Config.php';
29
30
        $this->date_time = $date_time;
31
32
        $this->calendar_type = $calendar_type;
33
34
        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...
35
36
    }
37
38
    /**
39
   * Which day of year is current day.
40
   *
41
   * @since  Aug, 03 2015
42
   * @return integer
43
   */
44 View Code Duplication
    public function year()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
47
        $this->config = include __DIR__.'/CalendarSettings/' . ucfirst($this->calendar_type) . '.php';
48
49
        return $this->config[ 'day_of_year' ]( $this->date_time );
50
51
    }
52
53
54
    /**
55
   * Which day of week is current day.
56
   *
57
   * @since  Aug, 09 2015
58
   * @return integer
59
   */
60 View Code Duplication
    public function week()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
    {
62
63
        $this->config = include __DIR__.'/CalendarSettings/' . ucfirst($this->calendar_type) . '.php';
64
65
        return $this->config[ 'day_of_week' ]( $this->date_time );
66
67
    }
68
69
	/**
70
	 * Return last day of current month
71
	 *
72
	 * @since  Oct, 18 2016
73
	 * @return integer
74
	 */
75 View Code Duplication
	public function lastDayMonth() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
77
		$this->config = include __DIR__.'/CalendarSettings/' . ucfirst($this->calendar_type) . '.php';
78
79
		return $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ];
80
81
	}
82
}
83