Completed
Pull Request — master (#260)
by
unknown
01:24
created

UnsupportedCacheLockDriverProvider::canSolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Facade\Ignition\SolutionProviders;
4
5
use Exception;
6
use Facade\IgnitionContracts\BaseSolution;
7
use Facade\IgnitionContracts\HasSolutionsForThrowable;
8
use Throwable;
9
10
class UnsupportedCacheLockDriverProvider implements HasSolutionsForThrowable
11
{
12
    public function canSolve(Throwable $throwable): bool
13
    {
14
        if (! $throwable instanceof Exception) {
15
            return false;
16
        }
17
18
        return in_array($throwable->getMessage(), [
19
            'Call to undefined method Illuminate\Cache\FileStore::lock()',
20
            'Call to undefined method Illuminate\Cache\DatabaseStore::lock()',
21
            'Call to undefined method Illuminate\Cache\ApcStore::lock()',
22
        ]);
23
    }
24
25
    public function getSolutions(Throwable $throwable): array
26
    {
27
        return [
28
            BaseSolution::create('Your current cache driver does not support atomic locks.')
29
                ->setSolutionDescription('Consider switching your cache driver to `redis`, `memcached`, or `dynamodb`.')
30
                ->setDocumentationLinks(['Cache: Atomic Locks docs' => 'https://laravel.com/docs/7.x/cache#atomic-locks']),
31
        ];
32
    }
33
}
34