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
Branch master (9e3162)
by Dave
63:34
created

GeneratorCommand::handle()   B

Complexity

Conditions 11
Paths 17

Size

Total Lines 42
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 132

Importance

Changes 0
Metric Value
cc 11
eloc 27
nc 17
nop 0
dl 0
loc 42
ccs 0
cts 33
cp 0
crap 132
rs 7.3166
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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