Completed
Push — master ( 69fccb...ece5bb )
by David
11:52 queued 34s
created

ValidateUKMobileCommand::isNumberValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Commands;
4
5
use App\PhoneNumberValidator;
6
use Illuminate\Support\Collection;
7
use Illuminate\Support\Facades\File;
8
use Symfony\Component\Console\Exception\RuntimeException;
9
10
class ValidateUKMobileCommand extends BaseValidatorCommand
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'validate:uk-mobile
18
                            {source* : A list of numbers or files to validate against}
19
                            {--file : Specifies that the source is a list of files}
20
                            {--output= : Specifies that the output path}';
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Validate UK mobile numbers and ouput to a CSV';
28
29
    /**
30
     * @var array
31
     */
32
    protected $validCountryCodes = [
33
        'GB', 'GG', 'JE',
34
    ];
35
36
    /**
37
     * Make a validator for a given number.
38
     *
39
     * @param  mixed $number
40
     * @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...
41
     */
42
    public function makeValidatorForNumer($number): PhoneNumberValidator
43
    {
44
        return app(PhoneNumberValidator::class)->make($number, 'GB');
45
    }
46
47
    /**
48
     * Is the number valid?
49
     *
50
     * @param  App\PhoneNumberValidator $validator
51
     * @return bool
52
     */
53
    public function isNumberValid(PhoneNumberValidator $validator): bool
54
    {
55
        return ($validator->isValidMobile() && $validator->isValidForCountry($this->validCountryCodes));
56
    }
57
}
58