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.

Installer   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 19
c 1
b 0
f 0
dl 0
loc 59
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A writeConfig() 0 14 2
A publishLumenConfig() 0 9 2
A sendTestException() 0 3 1
A shouldPublishConfig() 0 3 1
A publishLaravelConfig() 0 5 1
1
<?php
2
3
namespace Honeybadger\HoneybadgerLaravel;
4
5
use Honeybadger\HoneybadgerLaravel\Contracts\Installer as InstallerContract;
6
use Honeybadger\HoneybadgerLaravel\Exceptions\TestException;
7
use Illuminate\Support\Facades\Artisan;
8
use InvalidArgumentException;
9
use sixlive\DotenvEditor\DotenvEditor;
10
11
class Installer implements InstallerContract
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function writeConfig(array $config, string $filePath): bool
17
    {
18
        try {
19
            $env = new DotenvEditor;
20
            $env->load($filePath);
21
        } catch (InvalidArgumentException $e) {
22
            return false;
23
        }
24
25
        collect($config)->each(function ($value, $key) use ($env) {
0 ignored issues
show
Bug introduced by
$config of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

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

25
        collect(/** @scrutinizer ignore-type */ $config)->each(function ($value, $key) use ($env) {
Loading history...
26
            $env->set($key, $value);
27
        });
28
29
        return $env->save();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function sendTestException(): array
36
    {
37
        return app('honeybadger.loud')->notify(new TestException);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function publishLaravelConfig(): bool
44
    {
45
        return Artisan::call('vendor:publish', [
46
            '--tag' => 'honeybadger-config',
47
        ]) === 0;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function shouldPublishConfig(): bool
54
    {
55
        return ! file_exists(base_path('config/honeybadger.php'));
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function publishLumenConfig(string $stubPath = null): 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