Skip to content

Commit

Permalink
Fix code smells in codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
makladuxbert committed Mar 23, 2018
1 parent 04f8cf9 commit 4dbe81b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Traits/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ public function hasRole($roles): bool
return $this->roles->contains('name', $roles->name ?? $roles);
}

foreach ($roles as $role) {
if ($this->hasRole($role)) {
return true;
}
}
$roles = \collect()->make($roles)->map(function ($role) {
return $role instanceof Role ? $role->name : $role;
});

return false;
return ! $roles->intersect($this->roles->pluck('name'))->isEmpty();
}

/**
Expand Down Expand Up @@ -202,6 +200,7 @@ public function hasAllRoles($roles): bool
if (\is_string($roles) || $roles instanceof Role) {
return $this->hasRole($roles);
}

$roles = \collect()->make($roles)->map(function ($role) {
return $role instanceof Role ? $role->name : $role;
});
Expand Down

0 comments on commit 4dbe81b

Please sign in to comment.