Completed
Push — master ( 65a329...e2aab6 )
by Marcel
01:21
created

RunningLaravelDuskInProductionProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canSolve() 0 8 2
A getSolutions() 0 9 1
1
<?php
2
3
namespace Facade\Ignition\SolutionProviders;
4
5
use Exception;
6
use Throwable;
7
use Facade\IgnitionContracts\BaseSolution;
8
use Facade\IgnitionContracts\HasSolutionsForThrowable;
9
10
class RunningLaravelDuskInProductionProvider implements HasSolutionsForThrowable
11
{
12
    public function canSolve(Throwable $throwable): bool
13
    {
14
        if (! $throwable instanceof Exception) {
15
            return false;
16
        }
17
18
        return $throwable->getMessage() === 'It is unsafe to run Dusk in production.';
19
    }
20
21
    public function getSolutions(Throwable $throwable): array
22
    {
23
        return [
24
            BaseSolution::create('Laravel Dusk should not be run in production.')
25
                ->setSolutionDescription('Install the dependencies with the `--no-dev` flag.'),
26
            BaseSolution::create('Laravel Dusk can be run in other environments.')
27
                ->setSolutionDescription('Consider setting the `APP_ENV` to something other than `production` like `local` for example.'),
28
        ];
29
    }
30
}
31