NumberParseException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 68
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A countryRequired() 0 11 1
A countryMismatch() 0 14 2
A getNumber() 0 4 1
A getCountries() 0 4 1
1
<?php namespace Propaganistas\LaravelPhone\Exceptions;
2
3
use Illuminate\Support\Str;
4
use libphonenumber\NumberParseException as libNumberParseException;
5
6
class NumberParseException extends libNumberParseException
7
{
8
    /**
9
     * @var string
10
     */
11
    protected $number;
12
13
    /**
14
     * @var array
15
     */
16
    protected $countries = [];
17
18
    /**
19
     * Country specification required static constructor.
20
     *
21
     * @param string $number
22
     * @return static
23
     */
24 33
    public static function countryRequired($number)
25
    {
26 33
        $exception = new static(
27 33
            libNumberParseException::INVALID_COUNTRY_CODE,
28 33
            'Number requires a country to be specified.'
29
        );
30
31 33
        $exception->number = $number;
32
33 33
        return $exception;
34
    }
35
36
    /**
37
     * Country mismatch static constructor.
38
     *
39
     * @param string $number
40
     * @param string|array $country
0 ignored issues
show
Bug introduced by
There is no parameter named $country. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
41
     * @return static
42
     */
43 30
    public static function countryMismatch($number, $countries)
44
    {
45 30
        $countries = array_filter(is_array($countries) ? $countries : [$countries]);
46
47 30
        $exception = new static(
48 30
            libNumberParseException::INVALID_COUNTRY_CODE,
49 30
            'Number does not match the provided '. Str::plural('country', count($countries)).'.'
50
        );
51
52 30
        $exception->number = $number;
53 30
        $exception->countries = $countries;
54
55 30
        return $exception;
56
    }
57
58
    /**
59
     * @return string
60
     */
61 3
    public function getNumber()
62
    {
63 3
        return $this->number;
64
    }
65
66
    /**
67
     * @return array
68
     */
69 3
    public function getCountries()
70
    {
71 3
        return $this->countries;
72
    }
73
}