DateFormatComparator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A matches() 0 4 1
A __construct() 0 4 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