public function when(callable $predicate): self
    {
        $layer = new self();
        $layer->parent = $this;
        $layer->predicates[] = $predicate;

        $this->layers[] = $layer;

        return $layer;
    }
public function when(callable $predicate): self
    {
        $layer = new self();
        $layer->parent = $this;
        $layer->predicates[] = $predicate;

        $this->layers[] = $layer;

        return $layer;
    }
public function when ( callable $ predicate ) : self { $ layer = new self ( ) ; $ layer -> parent = $ this ; $ layer -> predicates [ ] = $ predicate ; $ this -> layers [ ] = $ layer ; return $ layer ; }
Creates a new matching layer with the given predicate and returns it.

The predicate must be a callable that accepts a {@see RequestInterface} instance as first parameter and returns a
boolean that represents whether the request matches the predicate's criteria.

@param callable $predicate

@return self The new matching layer
Creates a new matching layer with the given predicate and returns it .