1 | <?php |
||
9 | class OptimusGenerateCommand extends Command |
||
10 | { |
||
11 | /** |
||
12 | * The console command name. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $name = 'hashid:optimus'; |
||
17 | |||
18 | /** |
||
19 | * The console command description. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description = 'Generate Optimus numbers'; |
||
24 | |||
25 | /** |
||
26 | * Execute the console command. |
||
27 | * |
||
28 | * @return mixed |
||
29 | */ |
||
30 | 1 | public function handle() |
|
31 | { |
||
32 | 1 | $this->table( |
|
33 | 1 | ['prime', 'inverse', 'random'], |
|
34 | 1 | $this->generateOptimusNumbers( |
|
35 | 1 | $this->getTimes(), |
|
36 | 1 | (int) $this->option('prime') ?: null |
|
37 | 1 | ) |
|
38 | 1 | ); |
|
39 | 1 | } |
|
40 | |||
41 | /** |
||
42 | * Get "times" option value. |
||
43 | * |
||
44 | * @return int |
||
45 | */ |
||
46 | 1 | protected function getTimes() |
|
52 | |||
53 | /** |
||
54 | * Generate Optimus numbers. |
||
55 | * |
||
56 | * @param int $times |
||
57 | * @param int $prime |
||
58 | * @return array |
||
59 | */ |
||
60 | 1 | protected function generateOptimusNumbers($times = 1, $prime = null) |
|
70 | |||
71 | /** |
||
72 | * Get the console command options. |
||
73 | * |
||
74 | * @return array |
||
75 | */ |
||
76 | 2 | protected function getOptions() |
|
83 | } |
||
84 |