ValidateUKMobileCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isNumberValid() 0 3 2
A makeValidatorForNumer() 0 3 1
1
<?php
2
3
namespace App\Commands;
4
5
use App\PhoneNumberValidator;
6
use Illuminate\Support\Facades\File;
7
8
class ValidateUKMobileCommand extends BaseValidatorCommand
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'validate:uk-mobile
16
                            {source* : A list of numbers or files to validate against}
17
                            {--file : Specifies that the source is a list of files}
18
                            {--output= : Specifies that the output path}';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Validate UK mobile numbers and ouput to a CSV';
26
27
    /**
28
     * @var array
29
     */
30
    protected $validCountryCodes = [
31
        'GB', 'GG', 'JE',
32
    ];
33
34
    /**
35
     * Make a validator for a given number.
36
     *
37
     * @param  mixed $number
38
     * @return App\PhoneNumberValidator
0 ignored issues
show
Bug introduced by
The type App\Commands\App\PhoneNumberValidator was not found. Did you mean App\PhoneNumberValidator? If so, make sure to prefix the type with \.
Loading history...
39
     */
40 5
    public function makeValidatorForNumer($number): PhoneNumberValidator
41
    {
42 5
        return app(PhoneNumberValidator::class)->make($number, 'GB');
43
    }
44
45
    /**
46
     * Is the number valid?
47
     *
48
     * @param  App\PhoneNumberValidator $validator
49
     * @return bool
50
     */
51 5
    public function isNumberValid(PhoneNumberValidator $validator): bool
52
    {
53 5
        return $validator->isValidMobile() && $validator->isValidForCountry($this->validCountryCodes);
54
    }
55
}
56