Completed
Pull Request — master (#121)
by
unknown
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 Throwable;
6
use Exception;
7
use Facade\IgnitionContracts\BaseSolution;
8
use Facade\Ignition\Solutions\GenerateAppKeySolution;
9
use Facade\IgnitionContracts\HasSolutionsForThrowable;
10
11
class RunningLaravelDuskInProductionProvider implements HasSolutionsForThrowable
12
{
13
    public function canSolve(Throwable $throwable): bool
14
    {
15
        if (! $throwable instanceof Exception) {
16
            return false;
17
        }
18
19
        return $throwable->getMessage() === 'It is unsafe to run Dusk in production.';
20
    }
21
22
    public function getSolutions(Throwable $throwable): array
23
    {
24
        return [
25
            BaseSolution::create('Laravel Dusk should not be run in production.')
26
                ->setSolutionDescription('Install the dependencies with the `--no-dev` flag.'),
27
            BaseSolution::create('Laravel Dusk can be run in other environments.')
28
                ->setSolutionDescription('Consider setting the `APP_ENV` to something other than `production` like `local` for example.'),
29
        ];
30
    }
31
}
32