Completed
Pull Request — master (#243)
by Luc
05:28
created

OpeningHour::equalHours()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3;
4
5
use ValueObjects\DateTime\Time;
6
use ValueObjects\DateTime\WeekDay;
7
8
class OpeningHour
9
{
10
    /**
11
     * @var WeekDay[]
12
     */
13
    private $weekDays;
14
15
    /**
16
     * @var Time
17
     */
18
    private $opens;
19
20
    /**
21
     * @var Time
22
     */
23
    private $closes;
24
25
    /**
26
     * OpeningHour constructor.
27
     * @param WeekDay $weekDay
28
     * @param Time $opens
29
     * @param Time $closes
30
     */
31
    public function __construct(
32
        WeekDay $weekDay,
33
        Time $opens,
34
        Time $closes
35
    ) {
36
        $this->weekDays[] = $weekDay;
37
        $this->opens = $opens;
38
        $this->closes = $closes;
39
    }
40
41
    /**
42
     * @param OpeningHour $otherOpeningHour
43
     * @return bool
44
     */
45
    public function equalHours(OpeningHour $otherOpeningHour)
46
    {
47
        return $otherOpeningHour->getOpens()->sameValueAs($this->getOpens()) &&
48
            $otherOpeningHour->getCloses()->sameValueAs($this->getCloses());
49
    }
50
51
    /**
52
     * @param OpeningHour $otherOpeningHour
53
     */
54
    public function mergeWeekday(OpeningHour $otherOpeningHour)
55
    {
56
        $this->weekDays[] = $otherOpeningHour->getWeekDays()[0];
57
    }
58
59
    /**
60
     * @return WeekDay[]
61
     */
62
    public function getWeekDays()
63
    {
64
        return $this->weekDays;
65
    }
66
67
    /**
68
     * @return Time
69
     */
70
    public function getOpens()
71
    {
72
        return $this->opens;
73
    }
74
75
    /**
76
     * @return Time
77
     */
78
    public function getCloses()
79
    {
80
        return $this->closes;
81
    }
82
}
83