Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
37 | public function getPermissions(UserPermissionInterface $user = null) : array |
||
38 | { |
||
39 | $cacheID = $this->cachePrefix.$user->getId(); |
||
|
|||
40 | $permissions = $this->cacheHelper->get($cacheID); |
||
41 | if ($permissions === null) { |
||
42 | $permissions = $this->getUserPermissions($user); |
||
43 | if ( $permissions !== [] ){ |
||
44 | $this->cacheHelper->save($cacheID, $permissions); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | return $permissions; |
||
49 | } |
||
50 | |||
59 | } |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: