CalendarTimePeriod::isValidPeriod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
class CalendarTimePeriod
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    // Attributes
7
8
    private $startTime;
9
    private $endTime;
10
11
    // Constructor
12
13
    public function __construct(CalendarTime $startTime, CalendarTime $endTime)
14
    {
15
        $this->setAttributes($startTime, $endTime);
16
    }
17
    
18
    // Functions
19
20
    public function setAttributes(CalendarTime $startTime, CalendarTime $endTime)
21
    {
22
        if ($this->isValidPeriod($startTime, $endTime)) {
23
            $this->startTime = $startTime;
24
            $this->endTime = $endTime;
25
        } else {
26
            user_error('CalendarTimePeriod::setAttributes() : you cannot construct a \'CalendarTimePeriod\' with the $startTime attribute superior or equal to the $endTime attribute', E_USER_ERROR);
27
        }
28
    }
29
    
30
    public function isValidPeriod(CalendarTime $startTime, CalendarTime $endTime)
31
    {
32
        return $startTime < $endTime;
33
    }
34
    
35
    public function getStartTime()
36
    {
37
        return $this->startTime;
38
    }
39
    public function getEndTime()
40
    {
41
        return $this->endTime;
42
    }
43
}
44