Test Failed
Push — master ( f47101...348e9e )
by Ricardo
02:03
created

CreditCard   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 1
A toDatabase() 0 3 1
A year() 0 3 1
A mounth() 0 3 1
A toUser() 0 3 1
A isSame() 0 3 1
1
<?php
2
3
namespace Validate;
4
5
class CreditCard extends \Faker\Provider\Payment implements \Validate\Contracts\Validate
6
{
7
8
    public static function toDatabase($creditCardNumber)
9
    {
10
        return strtoupper(preg_replace('/[^0-9]/', '', $creditCardNumber));
11
    }
12
13
    public static function toUser($creditCardNumber)
14
    {
15
        return strtoupper(preg_replace('/[^0-9]/', '', $creditCardNumber));
16
    }
17
18
    public static function validate($creditCardNumber)
19
    {
20
        return true;
21
    }
22
23
    public static function mounth($year)
24
    {
25
        return Date::validateMonth($year);
26
    }
27
28
    public static function year($year)
29
    {
30
        return Date::yearToDatabase($year);
31
    }
32
33
    public static function isSame(string $to, string $from)
34
    {
35
        return (self::toDatabase($to)===self::toDatabase($from));
36
    }
37
38
}
39