IdentityGetCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 51
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 16 3
1
<?php
2
3
namespace ArcherZdip\Identity\Console;
4
5
use Illuminate\Console\Command;
6
7
class IdentityGetCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'identity:get
15
                            {--l|limit= : Get identity number}
16
                            {--P|province= : Set province,like `北京市`}
17
                            {--S|sex= : Set Sex,like `男`}
18
                            {--B|birth= : Set birth,like xxxx-xx-xx}';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Get Chinese ID Number.';
26
27
    /**
28
     * Create a new command instance.
29
     *
30
     * @return void
31
     */
32
    public function __construct()
33
    {
34
        parent::__construct();
35
    }
36
37
    /**
38
     * Execute the console command.
39
     *
40
     * @return mixed
41
     */
42
    public function handle()
43
    {
44
        $limit = $this->option('limit');
45
        $province = $this->option('province');
46
        $sex = $this->option('sex');
47
        $birth = $this->option('birth');
48
49
        if (is_null($limit)) {
0 ignored issues
show
introduced by
The condition is_null($limit) is always false.
Loading history...
50
            $this->info( app('identity_faker')->province($province)
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
            $this->info( /** @scrutinizer ignore-call */ app('identity_faker')->province($province)
Loading history...
51
                ->sex($sex)->birth($birth)->one() );
52
        } else {
53
            $ids = app('identity_faker')->province($province)
54
                ->sex($sex)->birth($birth)->limit($limit)->get();
55
56
            foreach ($ids as $id) {
57
                $this->info($id);
58
            }
59
        }
60
    }
61
}
62