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.

KeyGenerateCommand::getOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * KeyGenerate.php.
4
 *
5
 * Description
6
 *
7
 * @author Milkmeowo <[email protected]>
8
 */
9
10
namespace Milkmeowo\Framework\Base\Console\Commands;
11
12
use Illuminate\Support\Str;
13
use Illuminate\Console\Command;
14
use Symfony\Component\Console\Input\InputOption;
15
16
class KeyGenerateCommand extends Command
17
{
18
    /**
19
     * The console command name.
20
     *
21
     * @var string
22
     */
23
    protected $name = 'key:generate';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = 'Set the application key';
31
32
    /**
33
     * Execute the console command.
34
     *
35
     * @return void
36
     */
37
    public function fire()
38
    {
39
        $key = $this->getRandomKey();
40
        if ($this->option('show')) {
41
            return $this->line('<comment>'.$key.'</comment>');
42
        }
43
        $path = base_path('.env');
44
        if (file_exists($path)) {
45
            file_put_contents(
46
                $path,
47
                str_replace(
48
                    'APP_KEY='.env('APP_KEY'),
49
                    'APP_KEY='.$key,
50
                    file_get_contents($path))
51
            );
52
        }
53
        $this->info("Application key [$key] set successfully.");
54
    }
55
56
    /**
57
     * Generate a random key for the application.
58
     *
59
     * @return string
60
     */
61
    protected function getRandomKey()
62
    {
63
        return Str::random(32);
64
    }
65
66
    /**
67
     * Get the console command options.
68
     *
69
     * @return array
70
     */
71
    protected function getOptions()
72
    {
73
        return [
74
            ['show', null, InputOption::VALUE_NONE, 'Simply display the key instead of modifying files.'],
75
        ];
76
    }
77
}
78