Completed
Push — master ( 934009...eebb8a )
by Peter
01:53
created

Assert::date()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 7
nc 2
nop 3
crap 3
1
<?php
2
3
namespace PtrTn\Battlerite\Assert;
4
5
use DateTime;
6
use Webmozart\Assert\Assert as BaseAssert;
7
8
class Assert extends BaseAssert
9
{
10 7
    public static function date($value, $format, $message = '')
11
    {
12 7
        $date = DateTime::createFromFormat($format, $value);
13 7
        if ($date === false) {
14 1
            static::reportInvalidArgument(sprintf(
15 1
                $message ?: 'Expected a valid date in format %s. Got: %s',
16 1
                $format,
17 1
                $value
18
            ));
19
        }
20 6
    }
21
}
22