IsSameDay   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 16
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 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