Completed
Pull Request — master (#8)
by steef
03:12
created

DayOfConstruction::generate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 13

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 5.5726

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 7
cts 13
cp 0.5385
rs 9.2
c 0
b 0
f 0
cc 4
eloc 13
nc 4
nop 0
crap 5.5726
1
<?php
2
3
namespace Stefanius\SpecialDates\Dates;
4
5
use Stefanius\SpecialDates\SDK\AbstractSpecialDate;
6
7 View Code Duplication
class DayOfConstruction extends AbstractSpecialDate
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9 3
    protected function generate()
10
    {
11 3
        $this->description = 'Dag van de Bouw';
12
13 3
        if ($this->year >= 2009) {
14
            $this->setupDateTimeObjects($this->generateDateTime($this->year, 6, 6));
15 3
        } else if ($this->year >= 2011) {
16
            $this->setupDateTimeObjects($this->generateDateTime($this->year, 5, 28));
17 3
        } else if ($this->year >= 2009) {
18
            $timestamp       = strtotime('first saturday', mktime(0, 0, 0, 6, 0, $this->year));
19
            $date = new \DateTime();
20
            $date->setTimestamp($timestamp);
21
22
            $this->setupDateTimeObjects($date);
23
        } else {
24 3
            $this->valid = false;
25
        }
26 3
    }
27
}
28