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

DutchPancakeDay::generate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5.3915

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 5
cts 14
cp 0.357
rs 9.3142
c 0
b 0
f 0
cc 3
eloc 15
nc 3
nop 0
crap 5.3915
1
<?php
2
3
namespace Stefanius\SpecialDates\Dates;
4
5
use Stefanius\SpecialDates\SDK\AbstractSpecialDate;
6
7
class DutchPancakeDay extends AbstractSpecialDate
8
{
9 3
    protected function generate()
10
    {
11 3
        $this->description = 'Pannenkoekendag';
12
13 3
        if ($this->year >= 2007) {
14
            if ($this->year === 2013) {
15
                $this->startDate = new \DateTime('2013-03-15');
16
                $this->endDate = new \DateTime('2013-03-15');
17
            } else {
18
                $timestamp       = strtotime('last friday', mktime(0, 0, 0, 4, 0, $this->year));
19
                $this->startDate = new \DateTime();
20
                $this->startDate->setTimestamp($timestamp);
21
                $this->endDate = new \DateTime();
22
                $this->endDate->setTimestamp($timestamp);
23
            }
24
25
            $this->totalLength = 1;
26
        } else {
27 3
            $this->valid = false;
28
        }
29 3
    }
30
}
31