1 | <?php |
||
2 | |||
3 | namespace Nip\Cache\Cacheable; |
||
4 | |||
5 | use League\Container\Exception\NotFoundException; |
||
0 ignored issues
–
show
|
|||
6 | use Nip\Cache\Stores\Repository; |
||
7 | use Nip\Container\Container; |
||
8 | use Symfony\Component\Cache\Adapter\ArrayAdapter; |
||
9 | |||
10 | /** |
||
11 | * Trait HasCacheStore |
||
12 | * @package Nip\Cache\Cacheable |
||
13 | */ |
||
14 | trait HasCacheStore |
||
15 | { |
||
16 | protected $cacheStore = null; |
||
17 | |||
18 | /** |
||
19 | * @return Repository |
||
20 | */ |
||
21 | 1 | protected function cacheStore() |
|
22 | { |
||
23 | 1 | if ($this->cacheStore === null) { |
|
24 | 1 | $this->cacheStore = $this->generateCacheStore(); |
|
25 | } |
||
26 | 1 | return $this->cacheStore; |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return Repository |
||
31 | */ |
||
32 | 1 | protected function generateCacheStore() |
|
33 | { |
||
34 | try { |
||
35 | 1 | return $this->generateCacheStoreFromContainer(); |
|
36 | } catch (NotFoundException $exception) { |
||
37 | return $this->generateCacheStoreInMemory(); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return Repository |
||
43 | */ |
||
44 | protected function generateCacheStoreInMemory() |
||
45 | { |
||
46 | $adapter = new ArrayAdapter(); |
||
47 | $store = new Repository($adapter); |
||
48 | return $store; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return Repository |
||
53 | * @throws NotFoundException |
||
54 | */ |
||
55 | 1 | protected function generateCacheStoreFromContainer() |
|
56 | { |
||
57 | 1 | if (function_exists('app')) { |
|
58 | 1 | return app('cache.store'); |
|
59 | } |
||
60 | |||
61 | return Container::getInstance()->get('cache.store'); |
||
62 | } |
||
63 | } |
||
64 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths