public function filter($value)
    {
        // Formats are applied exclusively and supersed filters
        if ($this->format) {
            if (!$this->serviceDescription) {
                throw new \RuntimeException('No service description was set so '
                    . 'the value cannot be formatted.');
            }
            return $this->serviceDescription->format($this->format, $value);
        }

        // Convert Boolean values
        if ($this->type == 'boolean' && !is_bool($value)) {
            $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
        }

        // Apply filters to the value
        if ($this->filters) {
            foreach ($this->filters as $filter) {
                if (is_array($filter)) {
                    // Convert complex filters that hold value place holders
                    foreach ($filter['args'] as &$data) {
                        if ($data == '@value') {
                            $data = $value;
                        } elseif ($data == '@api') {
                            $data = $this;
                        }
                    }
                    $value = call_user_func_array(
                        $filter['method'],
                        $filter['args']
                    );
                } else {
                    $value = call_user_func($filter, $value);
                }
            }
        }

        return $value;
    }
public function filter($value)
    {
        // Formats are applied exclusively and supersed filters
        if ($this->format) {
            if (!$this->serviceDescription) {
                throw new \RuntimeException('No service description was set so '
                    . 'the value cannot be formatted.');
            }
            return $this->serviceDescription->format($this->format, $value);
        }

        // Convert Boolean values
        if ($this->type == 'boolean' && !is_bool($value)) {
            $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
        }

        // Apply filters to the value
        if ($this->filters) {
            foreach ($this->filters as $filter) {
                if (is_array($filter)) {
                    // Convert complex filters that hold value place holders
                    foreach ($filter['args'] as &$data) {
                        if ($data == '@value') {
                            $data = $value;
                        } elseif ($data == '@api') {
                            $data = $this;
                        }
                    }
                    $value = call_user_func_array(
                        $filter['method'],
                        $filter['args']
                    );
                } else {
                    $value = call_user_func($filter, $value);
                }
            }
        }

        return $value;
    }
public function filter ( $ value ) { // Formats are applied exclusively and supersed filters if ( $ this -> format ) { if ( ! $ this -> serviceDescription ) { throw new \ RuntimeException ( 'No service description was set so ' . 'the value cannot be formatted.' ) ; } return $ this -> serviceDescription -> format ( $ this -> format , $ value ) ; } // Convert Boolean values if ( $ this -> type == 'boolean' && ! is_bool ( $ value ) ) { $ value = filter_var ( $ value , FILTER_VALIDATE_BOOLEAN ) ; } // Apply filters to the value if ( $ this -> filters ) { foreach ( $ this -> filters as $ filter ) { if ( is_array ( $ filter ) ) { // Convert complex filters that hold value place holders foreach ( $ filter [ 'args' ] as & $ data ) { if ( $ data == '@value' ) { $ data = $ value ; } elseif ( $ data == '@api' ) { $ data = $ this ; } } $ value = call_user_func_array ( $ filter [ 'method' ] , $ filter [ 'args' ] ) ; } else { $ value = call_user_func ( $ filter , $ value ) ; } } } return $ value ; }
Run a value through the filters OR format attribute associated with the
parameter.

@param mixed $value Value to filter

@return mixed Returns the filtered value
@throws \RuntimeException when trying to format when no service
description is available.
Run a value through the filters OR format attribute associated with the parameter .