/** * {@inheritdoc} */ public function relativize(Uri $relative) { if (!$relative instanceof HierarchicalUri) { return $relative; } if ($this->getScheme() !== $relative->getScheme() || $this->getAuthority() !== $relative->getAuthority()) { return $relative; } $relativePath = $this->path->modify($relative->getPath()); return $relative->withScheme('')->withUserInfo('')->withHost('')->withPort('')->withPath($this->path->relativize($relativePath)); }