Conditions | 6 |
Paths | 8 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function find(string $id, string $class, array $columns = []): ?Storable |
||
22 | { |
||
23 | $hash = $this->getHash($class, $id); |
||
24 | $model = $this->cacheRepository->find($id, $class, $columns); |
||
25 | if ($model) { |
||
26 | if ($columns) { |
||
27 | // If you wanna specified columns... |
||
28 | if (!array_diff($columns, array_keys($model->toArray()))) { |
||
29 | return $model; |
||
30 | } |
||
31 | } else { |
||
32 | // If you wanna all columns... |
||
33 | if ($this->allColumns->get($hash, false)) { |
||
34 | return $model; |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | $model = $this->repository->find($id, $class, $columns); |
||
39 | $this->cacheRepository->update($model); |
||
40 | if (!$columns) { |
||
41 | $this->allColumns->put($hash, true); |
||
42 | } |
||
43 | return $model; |
||
44 | } |
||
45 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.