DutchPancakeDay::generate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5.9245

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
ccs 5
cts 16
cp 0.3125
cc 3
eloc 15
nc 3
nop 0
crap 5.9245
1
<?php
2
3
namespace Stefanius\SpecialDates\Dates;
4
5
use Stefanius\SpecialDates\SDK\AbstractSpecialDate;
6
7
class DutchPancakeDay extends AbstractSpecialDate
8
{
9 2
    protected function generate()
10
    {
11 2
        $this->description = 'Pannenkoekendag';
12
13 2
        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 2
            $this->valid = false;
28
        }
29 2
    }
30
}
31