Completed
Pull Request — master (#121)
by
unknown
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 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