functions.php ➔ getEasterMonday()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace HansOtt\Holiday;
4
5
use DateInterval;
6
use DateTimeImmutable;
7
use HansOtt\Holiday\Calendar\Year;
8
9
function getNewYearsEve(Year $year)
10
{
11 4
    $time = sprintf('first day of January %s', $year);
12
13 4
    return new DateTimeImmutable($time);
14
}
15
16
/**
17
 * Get easter monday.
18
 *
19
 * @param Year $year
20
 *
21
 * @return DateTimeImmutable
22
 */
23
function getEasterMonday(Year $year)
24
{
25 2
    $year = $year->toInt();
26 2
    $time = sprintf('%d-03-21', $year);
27 2
    $base = new DateTimeImmutable($time);
28 2
    $days = easter_days($year, CAL_EASTER_ALWAYS_GREGORIAN);
29 2
    $intervalSpec = sprintf('P%dD', $days + 1);
30 2
    $daysInterval = new DateInterval($intervalSpec);
31
32 2
    return $base->add($daysInterval);
33
}
34
35
function getEndOfDay(DateTimeImmutable $day)
36
{
37 4
    return $day->setTime(23, 59, 59);
38
}
39