ToDateTime   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A asDateTime() 0 5 1
1
<?php declare(strict_types=1);
2
3
4
namespace Pitchart\Phlunit\Checks\Converter;
5
6
use PHPUnit\Framework\Assert;
7
use Pitchart\Phlunit\Checks\DateTimeCheck;
8
9
/**
10
 * Class ToDateTime
11
 *
12
 * @package Pitchart\Phlunit\Checks\Converter
13
 *
14
 * @author Julien VITTE <[email protected]>
15
 *
16
 */
17
trait ToDateTime
18
{
19 2
    public function asDateTime(string $format = 'Y-m-d H:i:s'): DateTimeCheck
20
    {
21 2
        $date = \DateTimeImmutable::createFromFormat($format, (string) $this->value);
22 2
        Assert::assertInstanceOf(\DateTimeInterface::class, $date);
23 2
        return new DateTimeCheck($date);
24
    }
25
}
26