EverydayRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A isMatched() 4 4 2

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
9
namespace AnimeDb\SmartSleep\Rule;
10
11 View Code Duplication
class EverydayRule 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 5
    public function __construct($start, $end, $seconds)
22
    {
23 5
        $this->setStart($start);
24 5
        $this->setEnd($end);
25 5
        $this->setSeconds($seconds);
26 5
    }
27
28
    /**
29
     * @param \DateTimeImmutable $time
30
     *
31
     * @return bool
32
     */
33 5
    public function isMatched(\DateTimeImmutable $time)
34
    {
35 5
        return $this->start() <= $time->format('G') && $this->end() > $time->format('G');
36
    }
37
}
38