public function withPathPrefix(string $pathPrefix, bool $append = false): self
    {
        if ($pathPrefix === '') {
            return $this;
        }
        $newConstraints = $this->constraints;
        if (isset($newConstraints[self::CONSTRAINT_PATH_PREFIX])) {
            $pathPrefix = $append ? $newConstraints[self::CONSTRAINT_PATH_PREFIX] . $pathPrefix : $pathPrefix . $newConstraints[self::CONSTRAINT_PATH_PREFIX];
        }
        $newConstraints[self::CONSTRAINT_PATH_PREFIX] = $pathPrefix;
        return new static($newConstraints);
    }
public function withPathPrefix(string $pathPrefix, bool $append = false): self
    {
        if ($pathPrefix === '') {
            return $this;
        }
        $newConstraints = $this->constraints;
        if (isset($newConstraints[self::CONSTRAINT_PATH_PREFIX])) {
            $pathPrefix = $append ? $newConstraints[self::CONSTRAINT_PATH_PREFIX] . $pathPrefix : $pathPrefix . $newConstraints[self::CONSTRAINT_PATH_PREFIX];
        }
        $newConstraints[self::CONSTRAINT_PATH_PREFIX] = $pathPrefix;
        return new static($newConstraints);
    }
public function withPathPrefix ( string $ pathPrefix , bool $ append = false ) : self { if ( $ pathPrefix === '' ) { return $ this ; } $ newConstraints = $ this -> constraints ; if ( isset ( $ newConstraints [ self :: CONSTRAINT_PATH_PREFIX ] ) ) { $ pathPrefix = $ append ? $ newConstraints [ self :: CONSTRAINT_PATH_PREFIX ] . $ pathPrefix : $ pathPrefix . $ newConstraints [ self :: CONSTRAINT_PATH_PREFIX ] ; } $ newConstraints [ self :: CONSTRAINT_PATH_PREFIX ] = $ pathPrefix ; return new static ( $ newConstraints ) ; }
Create a new instance with the path prefix constraint added
This can be applied multiple times, later prefixes will be prepended to the start

@param string $pathPrefix The URI path prefix to force, for example "some-prefix/"
@param bool $append If true the $pathPrefix will be added *after* previous path prefix constraints. By default prefixes are added *before* any existing prefix
@return UriConstraints
Create a new instance with the path prefix constraint added This can be applied multiple times later prefixes will be prepended to the start