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

MissingMixManifestSolutionProvider::canSolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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