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

OpeningHour   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 2
cbo 1
dl 0
loc 75
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A equalHours() 0 5 2
A mergeWeekday() 0 4 1
A getWeekDays() 0 4 1
A getOpens() 0 4 1
A getCloses() 0 4 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