2022-03-23 22:27:15 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\View\Tests\Embed;
|
|
|
|
|
|
|
|
use Psr\Http\Message\UriInterface;
|
|
|
|
|
|
|
|
class MockUri implements UriInterface
|
|
|
|
{
|
|
|
|
private string $scheme;
|
|
|
|
private string $host;
|
|
|
|
private string $path;
|
|
|
|
private string $query;
|
|
|
|
|
|
|
|
public function __construct(string $url)
|
|
|
|
{
|
2022-04-14 03:12:59 +02:00
|
|
|
$p = parse_url($url ?? '');
|
2022-03-23 22:27:15 +01:00
|
|
|
$this->scheme = $p['scheme'] ?? '';
|
|
|
|
$this->host = $p['host'] ?? '';
|
|
|
|
$this->path = $p['path'] ?? '';
|
|
|
|
$this->query = $p['query'] ?? '';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getScheme()
|
|
|
|
{
|
|
|
|
return $this->scheme;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHost()
|
|
|
|
{
|
|
|
|
return $this->host;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPath()
|
|
|
|
{
|
|
|
|
return $this->path;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getQuery()
|
|
|
|
{
|
|
|
|
return $this->query;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPort()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAuthority()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUserInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFragment()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withPath($path)
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withScheme($scheme)
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withUserInfo($user, $password = null)
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withHost($host)
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withPort($port)
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withQuery($query)
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withFragment($fragment)
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
$query = $this->getQuery();
|
|
|
|
return sprintf(
|
|
|
|
'%s://%s%s%s',
|
|
|
|
$this->getScheme(),
|
|
|
|
$this->getHost(),
|
2022-04-14 03:12:59 +02:00
|
|
|
'/' . ltrim($this->getPath() ?? '', '/'),
|
2022-03-23 22:27:15 +01:00
|
|
|
$query ? "?$query" : ''
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|