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.

ExportControlCommand::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Export;
4
5
use BristolSU\ControlDB\Contracts\Repositories\Group;
6
use BristolSU\ControlDB\Contracts\Repositories\Position;
7
use BristolSU\ControlDB\Contracts\Repositories\Role;
8
use BristolSU\ControlDB\Contracts\Repositories\User;
9
use Illuminate\Console\Command;
10
use Symfony\Component\Console\Exception\InvalidArgumentException;
11
12
/**
13
 * Seed the database
14
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
15
class ExportControlCommand extends Command
16
{
17
    /**
18
     * Signature for the command
19
     * 
20
     * @var string 
21
     */
22
    protected $signature = 'control:export
23
                            {type : The type of resource to export}
24
                            {--exporter= : The name of the exporter to use}';
25
26
    /**
27
     * Name for the commmand
28
     * 
29
     * @var string 
30
     */
31
    protected $name = 'Export Control';
32
33
    /**
34
     * Description of the command
35
     * 
36
     * @var string 
37
     */
38
    protected $description = 'Export control to an external service';
39
40
    /**
41
     * Handle the command execution
42
     * 
43
     * Seed the database with fake data.
44
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
45 5
    public function handle()
46
    {
47 5
        $time=-hrtime(true);
48 5
        Exporter::driver($this->option('exporter'))->export($this->exportData());
0 ignored issues
show
Bug introduced by
The method driver() does not exist on BristolSU\ControlDB\Export\Exporter. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
        Exporter::/** @scrutinizer ignore-call */ 
49
                  driver($this->option('exporter'))->export($this->exportData());
Loading history...
49 5
        $this->info('Export complete');
50 5
        $time+=hrtime(true);
51 5
        $this->info(sprintf('Export took %.2f s to run', $time / 1e+9));
52 5
    }
53
54 5
    private function exportData()
0 ignored issues
show
Coding Style introduced by
Private method name "ExportControlCommand::exportData" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function exportData()
Loading history...
55
    {
56 5
        switch($this->argument('type')) {
57 5
            case 'user': 
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
58 2
                return app(User::class)->all();
59
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
60 3
            case 'group':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
61 1
                return app(Group::class)->all();
62
                break;
63 2
            case 'role':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
64 1
                return app(Role::class)->all();
65
                break;
66 1
            case 'position':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
67 1
                return app(Position::class)->all();
68
                break;
69
            default:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
70
                throw new InvalidArgumentException(sprintf('The type option %s is not allowed.', $this->argument('type')));
0 ignored issues
show
Bug introduced by
It seems like $this->argument('type') can also be of type string[]; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

70
                throw new InvalidArgumentException(sprintf('The type option %s is not allowed.', /** @scrutinizer ignore-type */ $this->argument('type')));
Loading history...
71
                break;
72
        }
73
    }
74
}