Completed
Push — master ( 1035b8...a1620e )
by Albert
03:30
created

DateAfter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Albert221\Validation\Rule;
4
5
use DateTime;
6
7 View Code Duplication
class DateAfter implements RuleInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    use RuleTrait;
10
11
    protected $date;
12
13 3
    public function __construct(DateTime $date)
14
    {
15 3
        $this->message = 'This field must have date following the specified date.';
16
17 3
        $this->date = $date;
18 3
    }
19
20 3
    public function test($value)
21
    {
22 3
        $value = $value instanceof DateTime ? $value : DateTime::createFromFormat(DateTime::W3C, $value);
23
24 3
        return $value > $this->date;
25
    }
26
}