GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#16)
by Raed
19:02
created

ShortenCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 56
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 14 2
1
<?php
2
3
namespace LaraCrafts\UrlShortener\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use LaraCrafts\UrlShortener\UrlShortenerManager;
7
8
class ShortenCommand extends Command
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'url:shorten
16
                            {url? : The URL to shorten}
17
                            {--D|driver= : The driver to use to shorten the URL.}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Shorten a given URL';
25
26
    /**
27
     * The URL Shortener instance.
28
     *
29
     * @var \LaraCrafts\UrlShortener\UrlShortenerManager
30
     */
31
    protected $shortener;
32
33
    /**
34
     * Create a new ShortenCommand instance.
35
     *
36
     * @param \LaraCrafts\UrlShortener\UrlShortenerManager $shortener
37
     */
38
    public function __construct(UrlShortenerManager $shortener)
39
    {
40
        parent::__construct();
41
42
        $this->shortener = $shortener;
43
    }
44
45
    /**
46
     * Execute the console command.
47
     *
48
     * @return mixed
49
     */
50
    public function handle()
51
    {
52
        $url = $this->argument('url') ?? $this->ask('Please enter the URL to shorten');
53
54
        if (!$url) {
55
            return $this->error('Aborted: No URL was given.');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->error('Aborted: No URL was given.') targeting Illuminate\Console\Command::error() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
56
        }
57
58
        $driver = $this->shortener->driver($this->option('driver'));
59
60
        $shortUrl = $driver->shorten($url);
61
62
        $this->info('URL shortened successfully.');
63
        $this->info("Your short URL is: $shortUrl");
64
    }
65
}
66