DateFormatComparator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php declare(strict_types=1);
2
3
4
namespace Pitchart\Phlunit\Constraint\DateTime;
5
6
use PHPUnit\Framework\Constraint\Constraint;
7
8
abstract class DateFormatComparator extends Constraint
9
{
10
    /**
11
     * @var \DateTimeInterface
12
     */
13
    protected $date;
14
15
    /**
16
     * @var string
17
     */
18
    protected $format;
19
20
    /**
21
     * IsSameUsingFormat constructor.
22
     *
23
     * @param \DateTimeInterface $date
24
     * @param $format
25
     */
26 23
    protected function __construct(\DateTimeInterface $date, string $format)
27
    {
28 23
        $this->date = $date;
29 23
        $this->format = $format;
30 23
    }
31
32 14
    protected function matches($other): bool
33
    {
34 14
        return $this->date->format($this->format)
35 14
            === $other->format($this->format);
36
    }
37
}
38