ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace LaravelDuskReporter;
4
5
use LaravelDuskReporter\Commands\PurgeFilesCommand;
6
7
class ServiceProvider extends \Illuminate\Support\ServiceProvider
8
{
9
    public function boot()
10
    {
11
        if ($this->app->runningInConsole()) {
12
            $this->commands([
13
                PurgeFilesCommand::class,
14
            ]);
15
            $this->publishes([
16
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/dusk-reporter'),
17
            ]);
18
        }
19
20
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'dusk-reporter');
21
    }
22
23
    public function register()
24
    {
25
        Reporter::$stopReporting      = (bool) getenv('DUSK_REPORT_DISABLED');
26
        Reporter::$disableScreenshots = (bool) getenv('DUSK_SCREENSHOTS_DISABLED');
27
        $this->app->bind(Reporter::class, function () {
28
            if (!Reporter::$storeBuildAt) {
29
                Reporter::$storeBuildAt = base_path(getenv('DUSK_REPORT_PATH') ?: 'storage/laravel-dusk-reporter');
30
            }
31
32
            return new Reporter();
33
        });
34
    }
35
}
36