PhoneNumber   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 8
c 3
b 0
f 0
dl 0
loc 27
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 2
1
<?php
2
3
namespace Soved\Laravel\Validation\PhoneNumber\Rules;
4
5
use Illuminate\Support\Facades\App;
6
use Brick\PhoneNumber\PhoneNumber as Validator;
7
use Brick\PhoneNumber\PhoneNumberParseException;
8
9
class PhoneNumber
10
{
11
    /**
12
     * Determine if the validation rule passes.
13
     *
14
     * @param  string  $attribute
15
     * @param  mixed  $value
16
     * @param  array  $parameters
17
     * @param  \Illuminate\Validation\Validator  $validator
0 ignored issues
show
Bug introduced by
The type Illuminate\Validation\Validator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
     * @return bool
19
     */
20
    public function __invoke(
21
        $attribute,
22
        $value = '',
23
        $parameters,
24
        $validator
25
    ) {
26
        try {
27
            $phoneNumber = Validator::parse(
28
                $value,
29
                strtoupper(App::getLocale())
30
            );
31
        } catch (PhoneNumberParseException $e) {
32
            return false;
33
        }
34
35
        return $phoneNumber->isValidNumber();
36
    }
37
}
38