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

DutchPancakeDay   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 35.7%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 24
ccs 5
cts 14
cp 0.357
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 21 3
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