public function insertBefore($class, $middleware)
    {
        $found = false;
        $i = null;
        foreach ($this->queue as $i => $object) {
            if ((is_string($object) && $object === $class)
                || is_a($object, $class)
            ) {
                $found = true;
                break;
            }
        }
        if ($found) {
            return $this->insertAt($i, $middleware);
        }
        throw new LogicException(sprintf("No middleware matching '%s' could be found.", $class));
    }
public function insertBefore($class, $middleware)
    {
        $found = false;
        $i = null;
        foreach ($this->queue as $i => $object) {
            if ((is_string($object) && $object === $class)
                || is_a($object, $class)
            ) {
                $found = true;
                break;
            }
        }
        if ($found) {
            return $this->insertAt($i, $middleware);
        }
        throw new LogicException(sprintf("No middleware matching '%s' could be found.", $class));
    }
public function insertBefore ( $ class , $ middleware ) { $ found = false ; $ i = null ; foreach ( $ this -> queue as $ i => $ object ) { if ( ( is_string ( $ object ) && $ object === $ class ) || is_a ( $ object , $ class ) ) { $ found = true ; break ; } } if ( $ found ) { return $ this -> insertAt ( $ i , $ middleware ) ; } throw new LogicException ( sprintf ( "No middleware matching '%s' could be found." , $ class ) ) ; }
Insert a middleware object before the first matching class.

Finds the index of the first middleware that matches the provided class,
and inserts the supplied callable before it.

@param string $class The classname to insert the middleware before.
@param callable|string $middleware The middleware to insert.
@return $this
@throws \LogicException If middleware to insert before is not found.
Insert a middleware object before the first matching class .