|
|
@ -2,10 +2,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace jrosset\UrlInfo;
|
|
|
|
namespace jrosset\UrlInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use GuzzleHttp\Psr7\Uri;
|
|
|
|
use jrosset\Collections\Collection;
|
|
|
|
use jrosset\Collections\Collection;
|
|
|
|
use jrosset\Collections\ICollection;
|
|
|
|
use jrosset\Collections\ICollection;
|
|
|
|
use jrosset\Collections\IImmutableCollection;
|
|
|
|
use jrosset\Collections\IImmutableCollection;
|
|
|
|
use jrosset\Collections\ImmutableCollection;
|
|
|
|
use jrosset\Collections\ImmutableCollection;
|
|
|
|
|
|
|
|
use Psr\Http\Message\UriInterface;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* An utils class about URL parts
|
|
|
|
* An utils class about URL parts
|
|
|
@ -71,6 +73,33 @@ class UrlInfo {
|
|
|
|
return $this->build();
|
|
|
|
return $this->build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Create from an {@see UriInterface}
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param UriInterface $uri The URI
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return static The new instance
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static function fromUriInterface (UriInterface $uri): self {
|
|
|
|
|
|
|
|
return new static ((string)$uri);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Create a new {@see Uri} from current URL
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return Uri The Uri instance
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function toUri (): Uri {
|
|
|
|
|
|
|
|
return new Uri($this->build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Create a new {@see UriInterface} from current URL
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return UriInterface The UriInterface instance
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function toUriInterface (): UriInterface {
|
|
|
|
|
|
|
|
return $this->toUri();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Ensure the return value is null if the given is an empty string
|
|
|
|
* Ensure the return value is null if the given is an empty string
|
|
|
|
*
|
|
|
|
*
|
|
|
|