src/Filterer/Filterer.php
public function filter($value)
    {
        foreach($this->getFilters() as $index => $filter) {
            // Extract the params
            list($method, $params) = $filter;

            // If method is null, we use the index as the method name
            $method = is_null($method) ? $index : $method;

            // Build the params for the filter
            array_unshift($params, $value);

            // If it's a anonymous function
            if (!is_string($method) && is_callable($method)) {

                $value = call_user_func_array($method, $params);

                // if it's a local method
            } else {

                if (!method_exists($this, $method)) {
                    throw new \Exception('Method "'. $method .'" not found for filter : ' . $index);
                }

                $value = call_user_func_array([$this, $method], $params);
            }
        }

        return $value;
    }
public function filter($value)
    {
        foreach($this->getFilters() as $index => $filter) {
            // Extract the params
            list($method, $params) = $filter;

            // If method is null, we use the index as the method name
            $method = is_null($method) ? $index : $method;

            // Build the params for the filter
            array_unshift($params, $value);

            // If it's a anonymous function
            if (!is_string($method) && is_callable($method)) {

                $value = call_user_func_array($method, $params);

                // if it's a local method
            } else {

                if (!method_exists($this, $method)) {
                    throw new \Exception('Method "'. $method .'" not found for filter : ' . $index);
                }

                $value = call_user_func_array([$this, $method], $params);
            }
        }

        return $value;
    }
public function filter ( $ value ) { foreach ( $ this -> getFilters ( ) as $ index => $ filter ) { // Extract the params list ( $ method , $ params ) = $ filter ; // If method is null, we use the index as the method name $ method = is_null ( $ method ) ? $ index : $ method ; // Build the params for the filter array_unshift ( $ params , $ value ) ; // If it's a anonymous function if ( ! is_string ( $ method ) && is_callable ( $ method ) ) { $ value = call_user_func_array ( $ method , $ params ) ; // if it's a local method } else { if ( ! method_exists ( $ this , $ method ) ) { throw new \ Exception ( 'Method "' . $ method . '" not found for filter : ' . $ index ) ; } $ value = call_user_func_array ( [ $ this , $ method ] , $ params ) ; } } return $ value ; }
Filter de value

Main method of the class

@param $value
@return mixed
@throws \Exception
Filter de value