Determine if a permission exactly matches the current instance

@param \BeatSwitch\Lock\Permissions\Permission $permission
@return bool
196638
public function matchesPermission(Permission $permission)
    {
        return (
            $this instanceof $permission &&
            $this->action === $permission->getAction() && // Not using matchesAction to avoid the wildcard
            $this->matchesResource($permission->getResource())
        );
    }
217857
public function findWithoutPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($user) use ($permission) {
                return $user->hasnt($permission);
            }
        );
    }
1343183
protected function hasPermissionThroughRole($permission): bool
    {
        foreach ($permission->roles as $role) {
            if ($this->roles->contains($role)) {
                return true;
            }
        }

        return false;
    }
113430
public function hasPermissionTo($permission): bool
    {
        if (is_string($permission)) {
            $permission = app(Permission::class)->findByName($permission, $this->getGuardName());
        }

        if ($permission->guard_name !== $this->getGuardName()) {
            throw GuardDoesNotMatch::create($permission->guard_name, $this->getGuardName());
        }

        return $this->permissions->contains('id', $permission->id);
    }
425270
protected function checkAccess($permission): bool
    {
        return $this->app->core->user->permissions[$this->app->getName()]->allowedTo($permission);
    }
142494
public function hasPermission($permission)
    {
        if ($this->isAdmin()) {
            return true;
        }

        if (is_null($this->permissions)) {
            $this->permissions = $this->getPermissions();
        }

        return in_array($permission, $this->permissions);
    }
148672
public function permission($administrator, $permission)
    {
        if (in_array($this->currentController, $this->administrators)) {
            return false;
        } elseif (in_array($this->currentController, $permission)) {
            return true;
        } else {
            return false;
        }
    }
1227753
public function checkPermissionTo($permission, $guardName = null): bool
    {
        try {
            return $this->hasPermissionTo($permission, $guardName);
        } catch (PermissionDoesNotExist $e) {
            return false;
        }
    }
245795
public function hasPermissions($permissions)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($permissions)) {
            $permissions = func_get_args();
        }

        // Count permissions because user need user to have all permissions passed as parameter
        return count(array_intersect($permissions, $this->permissions)) === count($permissions);
    }
1038512
public function assignPermission($permission)
    {
        return $this->mapArray($permission, function ($permission) {

            $permissionId = $this->parsePermissionId($permission);

            if ( ! $this->permissions->keyBy('id')->has($permissionId) ) {
                $this->permissions()->attach($permissionId);

                return $permission;
            }

            return false;
        });
    }
71104
public function can($permission)
    {
        $permissions = $this->getPermissions();

        if (is_array($permission)) {
            $permissionCount   = count($permission);
            $intersection      = array_intersect($permissions, $permission);
            $intersectionCount = count($intersection);

            return ($permissionCount == $intersectionCount) ? true : false;
        } else {
            return in_array($permission, $permissions);
        }
    }
119756
public function hasCallerPermission(Caller $caller, Permission $permission)
    {
        $query = $this->getTable()
            ->where('caller_type', $caller->getCallerType())
            ->where('caller_id', $caller->getCallerId())
            ->where('type', $permission->getType())
            ->where('action', $permission->getAction());

        if (is_null($permission->getResourceType())) {
            $query->whereNull('resource_type');
        } else {
            $query->where('resource_type', $permission->getResourceType());
        }

        if (is_null($permission->getResourceId())) {
            $query->whereNull('resource_id');
        } else {
            $query->where('resource_id', $permission->getResourceId());
        }

        return (bool) $query->first();
    }
396954
public function revokePermission($permission)
    {
        return $this->mapArray($permission, function ($permission) {

            $permissionId = $this->parsePermissionId($permission);

            return $this->permissions()->detach($permissionId);
        });
    }
580530
private function hasCharacterPermission(array $permission)
    {

        $map = $this->getAffiliationMap();

        // Owning a character grants you '*' permissions to the owned object. In this
        // context, '*' acts as a wildcard for *all* permissions
        foreach ($map['char'] as $char => $permissions) {

            // in case the permissions array is not related to the character for which we're requesting access
            // skip
            if ($char != $this->getCharacterId())
                continue;

            // in case a wildcard access has been assigned (user is owner), grant access
            if (in_array('character.*', $permissions))
                return true;

            // yeah, this is dumb. So if we have an array permission, we need to
            // loop and check each in there.
            foreach ($permission as $sub_permission) {

                // check only character wildcard and specific permission
                if (in_array($sub_permission, $permissions))
                    return true;
            }
        }

        return false;
    }
197411
public function hasDirectPermission($permission)
    {
        $name = $permission instanceof Permission ? $permission->name : $permission;
        return (bool) $this->permissions->where('name', $name)->count();
    }
444166
public function hasPermission($permission)
    {
        return (is_array($this->permissions) &&
                isset($this->permissions[$permission]) &&
                $this->permissions[$permission] == true
               ) ||
               (
                   isset($this->permissions['administrator']) &&
                $this->permissions['administrator'] == true
               );
    }
531218
public function hasPermission($recipient, $permission)
    {

        if ($recipient instanceof Group) {
            $check = true;
            foreach ($recipient->getLogins() as $login) {
                if ($this->hasLoginPermission($login, $permission) === false) {
                    $check = false;
                }
            }

            return $check;
        } else {
            return $this->hasLoginPermission($recipient, $permission);
        }
    }