Completed
Pull Request — master (#200)
by Travis
01:24
created

MissingMixManifestSolutionProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canSolve() 0 8 2
A getSolutions() 0 7 1
1
<?php
2
3
namespace Facade\Ignition\SolutionProviders;
4
5
use Facade\Ignition\Exceptions\ViewException;
6
use Illuminate\Support\Str;
7
use Throwable;
8
use Facade\IgnitionContracts\BaseSolution;
9
use Facade\IgnitionContracts\HasSolutionsForThrowable;
10
11
class MissingMixManifestSolutionProvider implements HasSolutionsForThrowable
12
{
13
    public function canSolve(Throwable $throwable): bool
14
    {
15
        if (! $throwable instanceof ViewException) {
16
            return false;
17
        }
18
19
        return Str::startsWith($throwable->getMessage(), 'The Mix manifest does not exist');
20
    }
21
22
    public function getSolutions(Throwable $throwable): array
23
    {
24
        return [
25
            BaseSolution::create('')
26
                ->setSolutionDescription('Generate the Mix manifest by using `npm install && npm run dev`.')
27
        ];
28
    }
29
}
30