Completed
Push — master ( b7fe7e...4bccf1 )
by Peter
01:34
created

WeekdayRule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 6
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 */
8
9
namespace AnimeDb\SmartSleep\Rule;
10
11 View Code Duplication
class WeekdayRule implements HourIntervalRule
12
{
13
    use HourlyIntervalRuleTrait;
14
    use RandSecondsRuleTrait;
15
16
    /**
17
     * @param int $start
18
     * @param int $end
19
     * @param int $seconds
20
     */
21 11
    public function __construct($start, $end, $seconds)
22
    {
23 11
        $this->setStart($start);
24 11
        $this->setEnd($end);
25 11
        $this->setSeconds($seconds);
26 11
    }
27
28
    /**
29
     * @param \DateTime $time
30
     *
31
     * @return bool
32
     */
33 11
    public function isMatched(\DateTime $time)
34
    {
35
        return
36 11
            $time->format('N') <= 5 &&
37 11
            $this->start() <= $time->format('G') &&
38 11
            $this->end() > $time->format('G')
39
        ;
40
    }
41
}
42