IsDateRegex::checkValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace kalanis\kw_rules\Rules\External;
4
5
6
use kalanis\kw_rules\Rules\MatchesPattern;
7
8
9
/**
10
 * Class IsDateRegex
11
 * @package kalanis\kw_rules\Rules\External
12
 * Check if input is date for preset format (YYYY-MM-DD)
13
 * @codeCoverageIgnore when I wrote tests I have zero will for defining all available dates to check
14
 */
15
class IsDateRegex extends MatchesPattern
16
{
17
    protected function checkValue(/** @scrutinizer ignore-unused */ $againstValue)
18
    {
19
        return '/^(((\d{4})(-)(0[13578]|10|12)(-)(0[1-9]|[12][0-9]|3[01]))|((\d{4})(-)(0[469]|11)(-)([0][1-9]|[12][0-9]|30))|((\d{4})(-)(02)(-)(0[1-9]|1[0-9]|2[0-8]))|(([02468][048]00)(-)(02)(-)(29))|(([13579][26]00)(-)(02)(-)(29))|(([0-9][0-9][0][48])(-)(02)(-)(29))|(([0-9][0-9][2468][048])(-)(02)(-)(29))|(([0-9][0-9][13579][26])(-)(02)(-)(29)))$/iu';
20
    }
21
}
22