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 (#11)
by TJ
06:05
created

Installer   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 19.64 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 5
dl 11
loc 56
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A writeConfig() 0 15 2
A sendTestException() 0 4 1
A publishLaravelConfig() 0 6 1
A publishLumenConfig() 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 Honeybadger\HoneybadgerLaravel;
4
5
use InvalidArgumentException;
6
use sixlive\DotenvEditor\DotenvEditor;
7
use Honeybadger\Contracts\Reporter as Honeybadger;
8
use Honeybadger\HoneybadgerLaravel\Exceptions\TestException;
9
use Honeybadger\HoneybadgerLaravel\Contracts\Installer as InstallerContract;
10
use Illuminate\Support\Facades\Artisan;
11
12
class Installer implements InstallerContract
13
{
14
    protected $honeybadger;
15
16
    public function __construct(Honeybadger $honeybadger)
17
    {
18
        $this->honeybadger = $honeybadger;
19
    }
20
21
    /**
22
     * Write the configurations to dotenv files.
23
     *
24
     * @param  array  $config
25
     * @param  string  $file
0 ignored issues
show
Bug introduced by
There is no parameter named $file. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
26
     * @return bool
27
     */
28
    public function writeConfig(array $config, string $filePath) : bool
29
    {
30
        try {
31
            $env = new DotenvEditor;
32
            $env->load($filePath);
33
        } catch (InvalidArgumentException $e) {
34
            return false;
35
        }
36
37
        collect($config)->each(function ($value, $key) use ($env) {
38
            $env->set($key, $value);
39
        });
40
41
        return $env->save();
42
    }
43
44
    public function sendTestException() : array
45
    {
46
        return $this->honeybadger->notify(new TestException);
47
    }
48
49
    public function publishLaravelConfig() : bool
50
    {
51
        return Artisan::call('vendor:publish', [
52
            '--provider' => HoneybadgerServiceProvider::class,
53
        ]) === 0;
54
    }
55
56 View Code Duplication
    public function publishLumenConfig(): bool
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...
57
    {
58
        if (! is_dir(base_path('config'))) {
59
            mkdir(base_path('config'));
60
        }
61
62
        return copy(
63
            __DIR__.'/../../config/honeybadger.php',
64
            base_path('config/honeybadger.php')
65
        );
66
    }
67
}
68