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
Push — master ( f91a4c...f91a4c )
by Dave
39:26 queued 34:22
created

SectionProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 47.83 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 22
loc 46
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fire() 11 11 2
A handle() 11 11 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace SleepingOwl\Admin\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Config\Repository;
7
use SleepingOwl\Admin\Console\Installation\CreateSectionServiceProvider;
8
9
class SectionProvider extends Command
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'sleepingowl:section:provider';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Create [AdminSectionsServiceProvider] class';
24
25
    /**
26
     * @param Repository $files
27
     */
28 View Code Duplication
    public function fire(Repository $files)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $installer = new CreateSectionServiceProvider($this, $files);
0 ignored issues
show
Documentation introduced by
$this is of type this<SleepingOwl\Admin\C...mmands\SectionProvider>, but the function expects a object<SleepingOwl\Admin...ommands\InstallCommand>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
        if ($installer->installed()) {
32
            $this->line('File <info>AdminSectionsServiceProvider</info> exists');
33
34
            return;
35
        }
36
37
        $installer->install();
38
    }
39
40
    /**
41
     * @param Repository $files
42
     */
43 View Code Duplication
    public function handle(Repository $files)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        $installer = new CreateSectionServiceProvider($this, $files);
0 ignored issues
show
Documentation introduced by
$this is of type this<SleepingOwl\Admin\C...mmands\SectionProvider>, but the function expects a object<SleepingOwl\Admin...ommands\InstallCommand>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46
        if ($installer->installed()) {
47
            $this->line('File <info>AdminSectionsServiceProvider</info> exists');
48
49
            return;
50
        }
51
52
        $installer->install();
53
    }
54
}
55