CardExpirationYear   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 45
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A passes() 0 5 1
A message() 0 4 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