ServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 37
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 19 5
A register() 0 4 1
1
<?php
2
namespace Rap2hpoutre\LaravelCreditCardValidator;
3
4
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
5
use Inacho\CreditCard;
6
7
class ServiceProvider extends BaseServiceProvider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     *
12
     * @return void
13
     */
14
    public function boot()
15
    {
16
        \Validator::extend('ccn', function($attribute, $value, $parameters, $validator) {
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
            return CreditCard::validCreditCard($value)['valid'];
18
        });
19
20
        \Validator::extend('ccd', function($attribute, $value, $parameters, $validator) {
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
            try {
22
                $value = explode('/', $value);
23
                return CreditCard::validDate(strlen($value[1]) == 2 ? (2000+$value[1]) : $value[1], $value[0]);
24
            } catch(\Exception $e) {
25
                return false;
26
            }
27
        });
28
29
        \Validator::extend('cvc', function($attribute, $value, $parameters, $validator) {
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
            return ctype_digit($value) && (strlen($value) == 3 || strlen($value) == 4);
31
        });
32
    }
33
    
34
    /**
35
     * Register the application services.
36
     *
37
     * @return void
38
     */
39
    public function register()
40
    {
41
        // 
42
    }
43
}
44