src/Permissions/PermissionFactory.php
public static function createFromObject($permission)
    {
        // Make sure the id is typecast to an integer.
        $id = ! is_null($permission->resource_id) ? (int) $permission->resource_id : null;

        if ($permission->type === Privilege::TYPE) {
            return new Privilege(
                $permission->action,
                new SimpleResource($permission->resource_type, $id)
            );
        } elseif ($permission->type === Restriction::TYPE) {
            return new Restriction(
                $permission->action,
                new SimpleResource($permission->resource_type, $id)
            );
        } else {
            throw new InvalidPermissionType("The permission type you provided \"{$permission->type}\" is incorrect.");
        }
    }
public static function createFromObject($permission)
    {
        // Make sure the id is typecast to an integer.
        $id = ! is_null($permission->resource_id) ? (int) $permission->resource_id : null;

        if ($permission->type === Privilege::TYPE) {
            return new Privilege(
                $permission->action,
                new SimpleResource($permission->resource_type, $id)
            );
        } elseif ($permission->type === Restriction::TYPE) {
            return new Restriction(
                $permission->action,
                new SimpleResource($permission->resource_type, $id)
            );
        } else {
            throw new InvalidPermissionType("The permission type you provided \"{$permission->type}\" is incorrect.");
        }
    }
public static function createFromObject ( $ permission ) { // Make sure the id is typecast to an integer. $ id = ! is_null ( $ permission -> resource_id ) ? ( int ) $ permission -> resource_id : null ; if ( $ permission -> type === Privilege :: TYPE ) { return new Privilege ( $ permission -> action , new SimpleResource ( $ permission -> resource_type , $ id ) ) ; } elseif ( $ permission -> type === Restriction :: TYPE ) { return new Restriction ( $ permission -> action , new SimpleResource ( $ permission -> resource_type , $ id ) ) ; } else { throw new InvalidPermissionType ( "The permission type you provided \"{$permission->type}\" is incorrect." ) ; } }
Maps an data object to a permission object

@param object $permission
@return \BeatSwitch\Lock\Permissions\Permission[]
@throws \BeatSwitch\Lock\Permissions\InvalidPermissionType
Maps an data object to a permission object