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 (#688)
by
unknown
18:52
created

GeneratorCommand   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 4
dl 0
loc 60
ccs 0
cts 38
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C handle() 0 45 11
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
     * Execute the console command.
31
     *
32
     * @return void
33
     */
34
    public function handle()
35
    {
36
        if (file_exists(base_path().'/vendor/compiled.php') ||
37
            file_exists(base_path().'/bootstrap/cache/compiled.php') ||
38
            file_exists(base_path().'/storage/framework/compiled.php')) {
39
            $this->error(
40
                'Error generating IDE Helper: first delete your compiled file (php artisan clear-compiled)'
41
            );
42
        } else {
43
            $filename = $this->argument('filename');
44
            $format = $this->option('format');
45
46
            // Strip the php extension
47
            if (substr($filename, -4, 4) == '.php') {
48
                $filename = substr($filename, 0, -4);
49
            }
50
51
            $filename .= '.'.$format;
52
53
            if ($this->option('memory')) {
54
                $this->useMemoryDriver();
55
            }
56
57
            $helpers = '';
58
            if ($this->option('helpers') || ($this->config->get('ide-helper.include_helpers'))) {
59
                foreach ($this->config->get('ide-helper.helper_files', []) as $helper) {
60
                    if (file_exists($helper)) {
61
                        $helpers .= str_replace(['<?php', '?>'], '', $this->files->get($helper));
62
                    }
63
                }
64
            } else {
65
                $helpers = '';
66
            }
67
68
            $generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers);
69
            $content = $generator->generate($format);
0 ignored issues
show
Bug introduced by
It seems like $format defined by $this->option('format') on line 44 can also be of type array; however, Barryvdh\LaravelIdeHelper\Generator::generate() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
70
            $written = $this->files->put($filename, $content);
71
72
            if ($written !== false) {
73
                $this->info("A new helper file was written to $filename");
74
            } else {
75
                $this->error("The helper file could not be created at $filename");
76
            }
77
        }
78
    }
79
}
80