Completed
Push — master ( 066e7f...6147b4 )
by Tyler
07:07
created

ServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 42
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
B register() 0 24 6
1
<?php 
2
3
namespace Tylercd100\Validator\Phone;
4
5
use Exception;
6
use Illuminate\Support\ServiceProvider as IlluminateProvider;
7
use Tylercd100\Validator\Phone\Validator;
8
9
class ServiceProvider extends IlluminateProvider
10
{
11
    /**
12
     * Bootstrap the application events.
13
     *
14
     * @return void
15
     */
16 21
    public function boot()
17
    {
18
19 21
    }
20
21
    /**
22
     * Register the service provider.
23
     *
24
     * @return void
25
     */
26 21
    public function register()
27
    {
28
        $this->app->resolving('validator', function ($factory, $app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app 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...
29
            
30 18
            $x = new Validator();
31
32 18
            $factory->extend('phone', function ($attribute, $value, $parameters, $validator) use ($x) {
0 ignored issues
show
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...
33 18
                if (count($parameters) > 0) {
34 12
                    switch ($parameters[0]) {
35 12
                        case 'e164':
36 12
                        case 'E164':
37 6
                            return $x->isE164($value);
0 ignored issues
show
Bug introduced by
The method isE164() cannot be called from this context as it is declared protected in class Tylercd100\Validator\Phone\Validator.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
38 6
                        case 'nanp':
39 6
                        case 'NANP':
40 3
                            return $x->isNANP($value);
0 ignored issues
show
Bug introduced by
The method isNANP() cannot be called from this context as it is declared protected in class Tylercd100\Validator\Phone\Validator.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
41 3
                        default:
42 3
                            throw new Exception($parameters[0]." is not a supported phone validation type.", 1);
43 3
                    }
44
                } else {
45 6
                    return $x->isPhone($value);
0 ignored issues
show
Bug introduced by
The method isPhone() cannot be called from this context as it is declared protected in class Tylercd100\Validator\Phone\Validator.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
46
                }
47 18
            }, "Not a valid phone number");
48 21
        });
49 21
    }
50
}
51