Total Complexity | 3 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class ShortenCommand extends Command |
||
10 | { |
||
11 | /** |
||
12 | * The console command name. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $name = 'shorten'; |
||
17 | |||
18 | /** |
||
19 | * The console command description. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description = 'Shorten a given URL'; |
||
24 | |||
25 | /** |
||
26 | * Execute the console command. |
||
27 | * |
||
28 | * @return mixed |
||
29 | */ |
||
30 | 24 | public function handle() |
|
31 | { |
||
32 | 24 | $driver = $this->laravel['url.shortener']->driver($this->input->getOption('driver')); |
|
33 | |||
34 | 24 | $shortUrl = $driver->shorten($this->input->getArgument('url')); |
|
35 | |||
36 | 24 | $this->info('URL shortened successfully.'); |
|
37 | 24 | $this->info("Your short URL is: $shortUrl"); |
|
38 | 24 | } |
|
39 | |||
40 | /** |
||
41 | * {@inheritDoc} |
||
42 | */ |
||
43 | 24 | protected function getArguments() |
|
44 | { |
||
45 | return [ |
||
46 | 24 | ['url', InputArgument::REQUIRED, 'The URL to shorten'], |
|
47 | ]; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritDoc} |
||
52 | */ |
||
53 | 24 | protected function getOptions() |
|
57 | ]; |
||
58 | } |
||
59 | } |
||
60 |