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.

GeneratorCommand   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 29
c 0
b 0
f 0
dl 0
loc 54
ccs 0
cts 28
cp 0
rs 10
wmc 11

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 42 11
1
<?php
2
3
namespace SleepingOwl\Admin\Console\Commands;
4
5
use Barryvdh\LaravelIdeHelper\Console\GeneratorCommand as IdeHelperGeneratorCommand;
6
use SleepingOwl\Admin\Console\Generator;
7
8
/**
9
 * A command to generate autocomplete information for your IDE.
10
 *
11
 * @author Aios Dave <[email protected]>
12
 */
13
class GeneratorCommand extends IdeHelperGeneratorCommand
14
{
15
    /**
16
     * The console command name.
17
     *
18
     * @var string
19
     */
20
    protected $name = 'sleepingowl:ide:generate';
21
22
    /**
23
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
24
     */
25
    public function handle()
26
    {
27
        if (file_exists(base_path().'/vendor/compiled.php') ||
28
            file_exists(base_path().'/bootstrap/cache/compiled.php') ||
29
            file_exists(base_path().'/storage/framework/compiled.php')) {
30
            $this->error(
31
                'Error generating IDE Helper: first delete your compiled file (php artisan clear-compiled)'
32
            );
33
        } else {
34
            $filename = (string) $this->argument('filename');
35
            $format = (string) $this->option('format');
36
37
            // Strip the php extension
38
            if (substr($filename, -4, 4) == '.php') {
39
                $filename = substr($filename, 0, -4);
40
            }
41
42
            $filename = implode('.', [$filename, $format]);
43
44
            if ($this->option('memory')) {
45
                $this->useMemoryDriver();
46
            }
47
48
            $helpers = '';
49
            if ($this->option('helpers') || ($this->config->get('ide-helper.include_helpers'))) {
50
                foreach ($this->config->get('ide-helper.helper_files', []) as $helper) {
51
                    if (file_exists($helper)) {
52
                        $helpers .= str_replace(['<?php', '?>'], '', $this->files->get($helper));
53
                    }
54
                }
55
            } else {
56
                $helpers = '';
57
            }
58
59
            $generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers);
60
            $content = $generator->generate($format);
61
            $written = (int) $this->files->put($filename, $content);
62
63
            if ($written === false) {
0 ignored issues
show
introduced by
The condition $written === false is always false.
Loading history...
64
                $this->error("The helper file could not be created at $filename");
65
            } else {
66
                $this->info("A new helper file was written to $filename");
67
            }
68
        }
69
    }
70
}
71