Test Failed
Push — master ( c78782...4767ee )
by Davis
05:32
created

WeekInterval::getYearWeek()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace DavisPeixoto\ReportDates;
4
5
use DateTime;
6
7
class WeekInterval
8
{
9
    /**
10
     * @var DateTime $start_date
11
     */
12
    private $start_date;
0 ignored issues
show
Coding Style introduced by
$start_date does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
13
14
    /**
15
     * @var DateTime $end_date
16
     */
17
    private $end_date;
0 ignored issues
show
Coding Style introduced by
$end_date does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
18
19
    /**
20
     * @var integer $interval
21
     */
22
    private $interval;
23
24
    public function __construct(DateTime $start_date, DateTime $end_date)
0 ignored issues
show
Coding Style introduced by
$start_date does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
25
    {
26
        $this->start_date = $start_date;
0 ignored issues
show
Coding Style introduced by
$start_date does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
27
        $this->end_date = $end_date;
0 ignored issues
show
Coding Style introduced by
$end_date does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
28
29
        $interval = $end_date->diff($start_date);
0 ignored issues
show
Coding Style introduced by
$end_date does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
30
        $this->interval = (int)$interval->format('%a') + 1;
31
    }
32
33
    /**
34
     * @return DateTime
35
     */
36
    public function getStartDate(): DateTime
37
    {
38
        return $this->start_date;
39
    }
40
41
    /**
42
     * @return DateTime
43
     */
44
    public function getEndDate(): DateTime
45
    {
46
        return $this->end_date;
47
    }
48
49
    /**
50
     * @return int
51
     */
52
    public function getWorkingDays(): int
53
    {
54
        return $this->interval;
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getWeekNumber(): string
61
    {
62
        return $this->end_date->format('W');
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getYearWeek(): string
69
    {
70
        return $this->end_date->format('oW');
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getYearMonth(): string
77
    {
78
        return $this->end_date->format('Ym');
79
    }
80
}
81