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

RunningLaravelDuskInProductionProvider::canSolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 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