Habari\ACL::access_check PHP Method

access_check() public static method

Check a permission bitmask for a particular access type.
public static access_check ( Bitmask $bitmask, mixed $access ) : boolean
$bitmask Bitmask The permission bitmask
$access mixed The name of the access to check against (read, write, full)
return boolean Returns true if the given access meets exceeds the access to check against
    public static function access_check($bitmask, $access)
    {
        if ($access instanceof Bitmask) {
            return ($bitmask->value & $access->value) == $access->value;
        }
        switch ($access) {
            case 'full':
                return $bitmask->value == $bitmask->full;
            case 'any':
                return $bitmask->value != 0;
            case 'deny':
                return $bitmask->value == 0;
            default:
                return $bitmask->{$access};
        }
    }