CardExpirationMonth::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace LVR\CreditCard;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class CardExpirationMonth implements Rule
8
{
9
    const MSG_CARD_EXPIRATION_MONTH_INVALID = 'validation.credit_card.card_expiration_month_invalid';
10
11
    /**
12
     * Year field name.
13
     *
14
     * @var string
15
     */
16
    protected $year;
17
18
    /**
19
     * CardExpirationMonth constructor.
20
     *
21
     * @param string $year
22
     */
23 1
    public function __construct($year)
24
    {
25 1
        $this->year = $year;
26 1
    }
27
28
    /**
29
     * Determine if the validation rule passes.
30
     *
31
     * @param  string $attribute
32
     * @param  mixed $value
33
     *
34
     * @return bool
35
     */
36 1
    public function passes($attribute, $value)
37
    {
38 1
        return (new ExpirationDateValidator($this->year, $value))
39 1
            ->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_MONTH_INVALID);
0 ignored issues
show
Bug Compatibility introduced by
The expression trans(static::MSG_CARD_EXPIRATION_MONTH_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