Completed
Push — master ( 0ebeda...45d090 )
by Peter
02:31
created

WeekdayRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 14
loc 14
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isMatched() 6 6 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 */
8
namespace AnimeDb\SmartSleep\Rule;
9
10 View Code Duplication
class WeekdayRule extends RandMaxSecondsRuleBase
11
{
12
    /**
13
     * @param \DateTime $time
14
     *
15
     * @return bool
16
     */
17 11
    public function isMatched(\DateTime $time)
18
    {
19 11
        return $time->format('N') <= 5 &&
20 11
            $this->getStart() <= $time->format('G') &&
21 11
            $this->getEnd() > $time->format('G');
22
    }
23
}
24