Add "clearDomain" and "keepDomainOnly" methods

master 1.5.0
Julien Rosset 2 years ago
parent b994ef40fd
commit 41ec33dc9b

@ -16,8 +16,8 @@
"minimum-stability": "stable",
"require": {
"php": "^7.4 || ^8.0",
"jrosset/collections": "^2.3 || ^3.0",
"guzzlehttp/psr7": "^2.4"
"jrosset/collections": "^2.3 || ^3.5",
"guzzlehttp/psr7": "^2.6"
},
"autoload": {
"psr-4": {

@ -1,4 +1,5 @@
<?php
/** @noinspection PhpUnused */
namespace jrosset\UrlInfo;
@ -10,7 +11,7 @@ use jrosset\Collections\ImmutableCollection;
use Psr\Http\Message\UriInterface;
/**
* An utils class about URL parts
* A utils class about URL parts
*/
class UrlInfo {
/**
@ -164,6 +165,30 @@ class UrlInfo {
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 ?
*

Loading…
Cancel
Save