Code Duplication    Length = 20-20 lines in 2 locations

src/Rule/DateAfter.php 1 location

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

src/Rule/DateBefore.php 1 location

@@ 7-26 (lines=20) @@
4
5
use DateTime;
6
7
class DateBefore implements RuleInterface
8
{
9
    use RuleTrait;
10
11
    protected $date;
12
13
    public function __construct(DateTime $date)
14
    {
15
        $this->message = 'This field must have date prior to the specified date.';
16
17
        $this->date = $date;
18
    }
19
20
    public function test($value)
21
    {
22
        $value = $value instanceof DateTime ? $value : DateTime::createFromFormat(DateTime::W3C, $value);
23
24
        return $value < $this->date;
25
    }
26
}