src/Pipe/FilterPipe.php
public static function createFilter($element)
    {
        if (is_callable($element)) {
            $filter = new CallbackFilter($element);
        } elseif (is_array($element) && isset($element['filter']) && is_callable($element['filter'])) {
            $filter = new CallbackFilter($element['filter']);
            unset($element['filter']);
        } elseif (is_array($element) && isset($element['filter']) && $element['filter'] instanceof FilterInterface) {
            $filter = $element['filter'];
            unset($element['filter']);
        } elseif ($element instanceof FilterInterface) {
            $filter = $element;
        } else {
            throw new InvalidArgumentException('Workflow::addFilter() must be called with either an instance of '.
                                               '"Plum\Plum\Filter\FilterInterface" or an array that contains '.
                                               '"filter".');
        }

        $pipe         = new self($element);
        $pipe->filter = $filter;

        return $pipe;
    }
public static function createFilter($element)
    {
        if (is_callable($element)) {
            $filter = new CallbackFilter($element);
        } elseif (is_array($element) && isset($element['filter']) && is_callable($element['filter'])) {
            $filter = new CallbackFilter($element['filter']);
            unset($element['filter']);
        } elseif (is_array($element) && isset($element['filter']) && $element['filter'] instanceof FilterInterface) {
            $filter = $element['filter'];
            unset($element['filter']);
        } elseif ($element instanceof FilterInterface) {
            $filter = $element;
        } else {
            throw new InvalidArgumentException('Workflow::addFilter() must be called with either an instance of '.
                                               '"Plum\Plum\Filter\FilterInterface" or an array that contains '.
                                               '"filter".');
        }

        $pipe         = new self($element);
        $pipe->filter = $filter;

        return $pipe;
    }
@param FilterInterface|callable|array $element

@return FilterPipe