Completed
Push — master ( 198800...1a9f17 )
by Propa
07:51
created

NumberParseException::getCountries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 24
    public static function countryRequired($number)
25
    {
26 24
        $exception = new static(
27 24
            libNumberParseException::INVALID_COUNTRY_CODE,
28 24
            'Number requires a country to be specified.'
29
        );
30
31 24
        $exception->number = $number;
32
33 24
        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 26
    public static function countryMismatch($number, $countries)
44
    {
45 26
        $countries = array_filter(is_array($countries) ? $countries : [$countries]);
46
47 26
        $exception = new static(
48 26
            libNumberParseException::INVALID_COUNTRY_CODE,
49 26
            'Number does not match the provided '. Str::plural('country', count($countries)).'.'
50
        );
51
52 26
        $exception->number = $number;
53 26
        $exception->countries = $countries;
54
55 26
        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
}