Skip to content

Commit 62160a7

Browse files
authored
reformatting (#16)
* formatting
1 parent 0780dba commit 62160a7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

phpstan-baseline.neon

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#2 \\$data of function hash_hmac expects string, string\\|false given\\.$#"
5+
count: 1
6+
path: src/LaravelPolicySoftCache.php

src/LaravelPolicySoftCache.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ protected function callPolicyMethod(Model $user, object $policy, string $ability
9797
*/
9898
protected function getCacheKey(Model $user, object $policy, array $args, string $ability): string
9999
{
100-
return get_class($user).'_'.$user->{$user->getKeyName()}.'_'.hash_hmac('sha512', (string) json_encode($args), config('app.key')).'_'.$ability.'_'.$policy::class;
100+
return collect([
101+
//the user class
102+
get_class($user),
103+
//the user id
104+
$user->{$user->getKeyName()},
105+
//hash of the arguments
106+
hash_hmac('sha512', json_encode($args), config('app.key')),
107+
$ability,
108+
get_class($policy),
109+
])->join('_');
101110
}
102111
}

0 commit comments

Comments
 (0)