Birthdate::toDatabase()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Validate;
4
5
use Carbon\Carbon;
6
7
class Birthdate extends Date implements \Validate\Contracts\Validate
8
{
9
    public static function toDatabase($birthdate)
10
    {
11
        return parent::toDatabase($birthdate);
12
    }
13
14
    public static function validate($birthdate)
15
    {   
16
        if (!parent::validate($birthdate)) {
17
            return false;
18
        }
19
20
        $birthdate = Carbon::createFromFormat('Y-m-d', self::toDatabase($birthdate));
21
        if ($birthdate->greaterThan(Carbon::now())) {
22
            return false;
23
        }
24
25
        return true;
26
    }
27
28
    public static function isSame(string $to, string $from)
29
    {
30
        return (self::toDatabase($to)===self::toDatabase($from));
31
    }
32
33
}
34