IsSameDay::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 10
cc 3
nc 2
nop 1
crap 3
1
<?php
2
/**
3
 * File was created 01.10.2015 18:02
4
 *
5
 * @author Karsten J. Gerber <[email protected]>
6
 */
7
8
namespace PeekAndPoke\Component\Psi\Psi;
9
10
use PeekAndPoke\Component\Psi\Functions\ParameterizedUnaryFunction;
11
use PeekAndPoke\Types\LocalDate;
12
13
/**
14
 * IsSameDay checks if a LocalDate is on the same day as the given parameter
15
 *
16
 * TODO: implement for normal \DateTime as well
17
 *
18
 * @see    ParameterizedUnaryFunction
19
 * @see    IsSameDayIsNotSameDayTest
20
 *
21
 * @author Karsten J. Gerber <[email protected]>
22
 */
23
class IsSameDay extends ParameterizedUnaryFunction
24
{
25
    /**
26
     * @param mixed $input
27
     *
28
     * @return bool
29
     */
30 28
    public function __invoke($input)
31
    {
32 28
        $val = $this->getValue();
33
34 28
        if (! $val instanceof LocalDate || ! $input instanceof LocalDate) {
35 8
            return false;
36
        }
37
38 20
        return $val->getStartOfDay()->isEqual($input->getStartOfDay());
39
    }
40
}
41