public function getInstance()
    {
        if ( ! $class = $this->getClassName())
        {
            $this->log->error(sprintf('"%s" will not be applied to asset "%s" due to an invalid filter name.', $this->filter, $this->resource->getRelativePath()));
        }

        if ($this->ignored or is_null($class) or ! $this->processRequirements()) return;

        // If the class returned is already implements Assetic\Filter\FilterInterface then
        // we can set the instance directly and not worry about using reflection.
        if ($class instanceof FilterInterface)
        {
            $instance = $class;
        }
        else
        {
            $reflection = new ReflectionClass($class);

            // If no constructor is available on the filters class then we'll instantiate
            // the filter without passing in any arguments.
            if ( ! $reflection->getConstructor())
            {
                $instance = $reflection->newInstance();
            }
            else
            {
                $instance = $reflection->newInstanceArgs($this->arguments);
            }
        }

        // Spin through each of the before filtering callbacks and fire each one. We'll
        // pass in an instance of the filter to the callback.
        foreach ($this->before as $callback)
        {
            if (is_callable($callback))
            {
                call_user_func($callback, $instance);
            }
        }

        return $instance;
    }