public static function requireId($parameters, $UINTEGER = true)
    {
        //Work with arrays
        if (is_object($parameters)) {
            $parameters = (array)$parameters;
        }

        if (isset($parameters['resource_id'])
            && preg_match(Validate::REGEXP_RESOURCE_ID, $parameters['resource_id']) !== false
        ) {
            $parameters['id'] = $parameters['resource_id'];
        }
        if (!isset($parameters['id'])) {
            throw new MissingParametersException(['id']);
        }

        //Validate as unsigned integer
        if ($UINTEGER
            && filter_var($parameters['id'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) === false
        ) {
            throw new IncorrectParametersException(['id']);
        } elseif (!$UINTEGER
            && preg_match(Validate::REGEXP_RESOURCE_ID, $parameters['id']) === false
        ) {
            //Validate as alphanumeric
            throw new IncorrectParametersException(['id']);
        }
        return ($UINTEGER ? intval($parameters['id']) : $parameters['id']);
    }
public static function requireId($parameters, $UINTEGER = true)
    {
        //Work with arrays
        if (is_object($parameters)) {
            $parameters = (array)$parameters;
        }

        if (isset($parameters['resource_id'])
            && preg_match(Validate::REGEXP_RESOURCE_ID, $parameters['resource_id']) !== false
        ) {
            $parameters['id'] = $parameters['resource_id'];
        }
        if (!isset($parameters['id'])) {
            throw new MissingParametersException(['id']);
        }

        //Validate as unsigned integer
        if ($UINTEGER
            && filter_var($parameters['id'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) === false
        ) {
            throw new IncorrectParametersException(['id']);
        } elseif (!$UINTEGER
            && preg_match(Validate::REGEXP_RESOURCE_ID, $parameters['id']) === false
        ) {
            //Validate as alphanumeric
            throw new IncorrectParametersException(['id']);
        }
        return ($UINTEGER ? intval($parameters['id']) : $parameters['id']);
    }
public static function requireId ( $ parameters , $ UINTEGER = true ) { //Work with arrays if ( is_object ( $ parameters ) ) { $ parameters = ( array ) $ parameters ; } if ( isset ( $ parameters [ 'resource_id' ] ) && preg_match ( Validate :: REGEXP_RESOURCE_ID , $ parameters [ 'resource_id' ] ) !== false ) { $ parameters [ 'id' ] = $ parameters [ 'resource_id' ] ; } if ( ! isset ( $ parameters [ 'id' ] ) ) { throw new MissingParametersException ( [ 'id' ] ) ; } //Validate as unsigned integer if ( $ UINTEGER && filter_var ( $ parameters [ 'id' ] , FILTER_VALIDATE_INT , [ 'options' => [ 'min_range' => 0 ] ] ) === false ) { throw new IncorrectParametersException ( [ 'id' ] ) ; } elseif ( ! $ UINTEGER && preg_match ( Validate :: REGEXP_RESOURCE_ID , $ parameters [ 'id' ] ) === false ) { //Validate as alphanumeric throw new IncorrectParametersException ( [ 'id' ] ) ; } return ( $ UINTEGER ? intval ( $ parameters [ 'id' ] ) : $ parameters [ 'id' ] ) ; }
Require id parameter, it uses `resource_id` or `id` parameter if available
@param  array|object $parameters The request paramters
@param  boolean      $UINTEGER  *[Optional]*, Check id's type to be unsigned integer, default is true
@throws \Phramework\Exceptions\IncorrectParameters When value is not correct
@throws \Phramework\Exceptions\MissingParametersException When id is missing
if $UINTEGER the returned value will be converted to unsigned integer
Require id parameter it uses resource_id or id parameter if available