CardExpirationYear::passes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace LVR\CreditCard;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class CardExpirationYear implements Rule
8
{
9
    const MSG_CARD_EXPIRATION_YEAR_INVALID = 'validation.credit_card.card_expiration_year_invalid';
10
11
    /**
12
     * Month field name.
13
     *
14
     * @var string
15
     */
16
    protected $month;
17
18
    /**
19
     * CardExpirationYear constructor.
20
     *
21
     * @param string $month
22
     */
23 2
    public function __construct($month)
24
    {
25 2
        $this->month = $month;
26 2
    }
27
28
    /**
29
     * Determine if the validation rule passes.
30
     *
31
     * @param  string $attribute
32
     * @param  mixed $value
33
     *
34
     * @return bool
35
     */
36 2
    public function passes($attribute, $value)
37
    {
38 2
        return (new ExpirationDateValidator($value, $this->month))
39 2
            ->isValid();
40
    }
41
42
    /**
43
     * Get the validation error message.
44
     *
45
     * @return string
46
     */
47 1
    public function message()
48
    {
49 1
        return trans(static::MSG_CARD_EXPIRATION_YEAR_INVALID);
0 ignored issues
show
Bug Compatibility introduced by
The expression trans(static::MSG_CARD_EXPIRATION_YEAR_INVALID); of type Illuminate\Contracts\Tra...lator|string|array|null adds the type Illuminate\Contracts\Translation\Translator to the return on line 49 which is incompatible with the return type declared by the interface Illuminate\Contracts\Validation\Rule::message of type string|array.
Loading history...
50
    }
51
}
52