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

UnsupportedCacheLockDriverProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canSolve() 0 12 2
A getSolutions() 0 8 1
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