|
|
@ -1,4 +1,5 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/** @noinspection PhpUnused */
|
|
|
|
|
|
|
|
|
|
|
|
namespace jrosset\UrlInfo;
|
|
|
|
namespace jrosset\UrlInfo;
|
|
|
|
|
|
|
|
|
|
|
@ -10,7 +11,7 @@ use jrosset\Collections\ImmutableCollection;
|
|
|
|
use Psr\Http\Message\UriInterface;
|
|
|
|
use Psr\Http\Message\UriInterface;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* An utils class about URL parts
|
|
|
|
* A utils class about URL parts
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class UrlInfo {
|
|
|
|
class UrlInfo {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -164,6 +165,30 @@ class UrlInfo {
|
|
|
|
return $url;
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Clear the “domain” parts of the URL and keep only path, arguments and anchor
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return $this
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function clearDomain (): self {
|
|
|
|
|
|
|
|
$this->setProtocol();
|
|
|
|
|
|
|
|
$this->setHost();
|
|
|
|
|
|
|
|
$this->setUser();
|
|
|
|
|
|
|
|
$this->setPass();
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Keep only the “domain” parts of the URL and clear path, arguments and anchor
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return $this
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function keepDomainOnly (): self {
|
|
|
|
|
|
|
|
$this->setPath();
|
|
|
|
|
|
|
|
$this->setArguments();
|
|
|
|
|
|
|
|
$this->setAnchor();
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Is the URL protocol set ?
|
|
|
|
* Is the URL protocol set ?
|
|
|
|
*
|
|
|
|
*
|
|
|
|