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 ( 4ae790...236d40 )
by TJ
02:47
created

Installer::shouldPublishConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Honeybadger\HoneybadgerLaravel;
4
5
use InvalidArgumentException;
6
use Honeybadger\Contracts\Reporter;
7
use Illuminate\Support\Facades\App;
8
use Illuminate\Support\Facades\Config;
9
use sixlive\DotenvEditor\DotenvEditor;
10
use Illuminate\Support\Facades\Artisan;
11
use Honeybadger\HoneybadgerLaravel\Exceptions\TestException;
12
use Honeybadger\HoneybadgerLaravel\Contracts\Installer as InstallerContract;
13
14
class Installer implements InstallerContract
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function writeConfig(array $config, string $filePath) : bool
20
    {
21
        try {
22
            $env = new DotenvEditor;
23
            $env->load($filePath);
24
        } catch (InvalidArgumentException $e) {
25
            return false;
26
        }
27
28
        collect($config)->each(function ($value, $key) use ($env) {
29
            $env->set($key, $value);
30
        });
31
32
        return $env->save();
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function sendTestException() : array
39
    {
40
        return App::makeWith(
41
            Reporter::class,
42
            ['config' => Config::get('honeybadger')]
43
        )->notify(new TestException);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function publishLaravelConfig() : bool
50
    {
51
        return Artisan::call('vendor:publish', [
52
            '--provider' => HoneybadgerServiceProvider::class,
53
        ]) === 0;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function shouldPublishConfig(): bool
60
    {
61
        return ! file_exists(base_path('config/honeybadger.php'));
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function publishLumenConfig(string $stubPath = null): bool
68
    {
69
        if (! is_dir(base_path('config'))) {
70
            mkdir(base_path('config'));
71
        }
72
73
        return copy(
74
            $stubPath ?? __DIR__.'/../config/honeybadger.php',
75
            base_path('config/honeybadger.php')
76
        );
77
    }
78
}
79