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
04:26
created

Installer::publishLumenConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Honeybadger\HoneybadgerLaravel;
4
5
use InvalidArgumentException;
6
use sixlive\DotenvEditor\DotenvEditor;
7
use Illuminate\Support\Facades\Artisan;
8
use Honeybadger\Contracts\Reporter as Honeybadger;
9
use Honeybadger\HoneybadgerLaravel\Exceptions\TestException;
10
use Honeybadger\HoneybadgerLaravel\Contracts\Installer as InstallerContract;
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
    public function shouldPublishConfig(): bool
57
    {
58
        return ! file_exists(base_path('config/honeybadger.php'));
59
    }
60
61
    public function publishLumenConfig(string $stubPath = ''): bool
62
    {
63
        if (! is_dir(base_path('config'))) {
64
            mkdir(base_path('config'));
65
        }
66
67
        return copy(
68
            $stubPath ?? __DIR__.'/../../config/honeybadger.php',
69
            base_path('config/honeybadger.php')
70
        );
71
    }
72
}
73