| Conditions | 6 | 
| Paths | 8 | 
| Total Lines | 22 | 
| Code Lines | 15 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 25 | public function find(string $id, string $class, array $columns = []): ?Storable | ||
| 26 |     { | ||
| 27 | $hash = $this->getHash($id, $class); | ||
| 28 | $model = $this->cacheRepository->find($id, $class, $columns); | ||
| 29 |         if ($model) { | ||
| 30 |             if ($columns) { | ||
|  | |||
| 31 |                 if (!array_diff($columns, array_keys($model->toArray()))) { | ||
| 32 | return $model; | ||
| 33 | } | ||
| 34 |             } else { | ||
| 35 |                 if (CacheDecorator::$allColumnsHashes[$hash] ?? false) { | ||
| 36 | return $model; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | } | ||
| 40 | $model = $this->repository->find($id, $class, $columns); | ||
| 41 | $this->cacheRepository->update($model); | ||
| 42 |         if (!$columns) { | ||
| 43 | CacheDecorator::$allColumnsHashes[$hash] = true; | ||
| 44 | } | ||
| 45 | return $model; | ||
| 46 | } | ||
| 47 | } | 
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.