|
|
|
@ -13,6 +13,7 @@ class Address
@@ -13,6 +13,7 @@ class Address
|
|
|
|
|
private ?int $_port = null; |
|
|
|
|
private ?string $_path = null; |
|
|
|
|
private ?string $_query = null; |
|
|
|
|
private ?string $_fragment = null; |
|
|
|
|
|
|
|
|
|
private array $_dirs = []; |
|
|
|
|
|
|
|
|
@ -70,6 +71,13 @@ class Address
@@ -70,6 +71,13 @@ class Address
|
|
|
|
|
(string) $query |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($fragment = parse_url($address, PHP_URL_FRAGMENT)) |
|
|
|
|
{ |
|
|
|
|
$this->setFragment( |
|
|
|
|
(string) $fragment |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -83,62 +91,62 @@ class Address
@@ -83,62 +91,62 @@ class Address
|
|
|
|
|
return !$this->isAbsolute(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getScheme(): string |
|
|
|
|
public function getScheme(): ?string |
|
|
|
|
{ |
|
|
|
|
return $this->_scheme; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setScheme(string $value): void |
|
|
|
|
public function setScheme(?string $value): void |
|
|
|
|
{ |
|
|
|
|
$this->_scheme = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getHost(): string |
|
|
|
|
public function getHost(): ?string |
|
|
|
|
{ |
|
|
|
|
return $this->_host; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setHost(string $value): void |
|
|
|
|
public function setHost(?string $value): void |
|
|
|
|
{ |
|
|
|
|
$this->_host = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getUser(): string |
|
|
|
|
public function getUser(): ?string |
|
|
|
|
{ |
|
|
|
|
return $this->_user; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setUser(string $value): void |
|
|
|
|
public function setUser(?string $value): void |
|
|
|
|
{ |
|
|
|
|
$this->_user = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getPass(): string |
|
|
|
|
public function getPass(): ?string |
|
|
|
|
{ |
|
|
|
|
return $this->_pass; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setPass(string $value): void |
|
|
|
|
public function setPass(?string $value): void |
|
|
|
|
{ |
|
|
|
|
$this->_pass = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getPort(): int |
|
|
|
|
public function getPort(): ?int |
|
|
|
|
{ |
|
|
|
|
return $this->_port; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setPort(int $value): void |
|
|
|
|
public function setPort(?int $value): void |
|
|
|
|
{ |
|
|
|
|
$this->_port = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getPath(): string |
|
|
|
|
public function getPath(): ?string |
|
|
|
|
{ |
|
|
|
|
return $this->_path; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setPath(string $value): void |
|
|
|
|
public function setPath(?string $value): void |
|
|
|
|
{ |
|
|
|
|
if (false !== strpos($value, '\\')) |
|
|
|
|
{ |
|
|
|
@ -158,23 +166,136 @@ class Address
@@ -158,23 +166,136 @@ class Address
|
|
|
|
|
return $this->_dirs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getQuery(): string |
|
|
|
|
public function getQuery(): ?string |
|
|
|
|
{ |
|
|
|
|
return $this->_query; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setQuery(string $value): void |
|
|
|
|
public function setQuery(?string $value): void |
|
|
|
|
{ |
|
|
|
|
$this->_query = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getFragment(): ?string |
|
|
|
|
{ |
|
|
|
|
return $this->_fragment; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setFragment(?string $value): void |
|
|
|
|
{ |
|
|
|
|
$this->_fragment = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getSeparator(): string |
|
|
|
|
{ |
|
|
|
|
return $this->_separator; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function absolute(string $address): string |
|
|
|
|
public function get(): string |
|
|
|
|
{ |
|
|
|
|
$address = ''; |
|
|
|
|
|
|
|
|
|
if ($scheme = $this->getScheme()) |
|
|
|
|
{ |
|
|
|
|
$address .= sprintf( |
|
|
|
|
'%s://', |
|
|
|
|
$scheme |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($user = $this->getUser()) |
|
|
|
|
{ |
|
|
|
|
if ($pass = $this->getPass()) |
|
|
|
|
{ |
|
|
|
|
$address .= sprintf( |
|
|
|
|
'%s:%s@', |
|
|
|
|
$user, |
|
|
|
|
pass |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$address .= sprintf( |
|
|
|
|
'%s@', |
|
|
|
|
$user |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($host = $this->getHost()) |
|
|
|
|
{ |
|
|
|
|
$address .= $host; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($port = $this->getPort()) |
|
|
|
|
{ |
|
|
|
|
$address .= sprintf( |
|
|
|
|
':%d', |
|
|
|
|
$port |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($path = $this->getPath()) |
|
|
|
|
{ |
|
|
|
|
$address .= sprintf( |
|
|
|
|
'%s%s', |
|
|
|
|
$this->getSeparator(), |
|
|
|
|
trim( |
|
|
|
|
$path, |
|
|
|
|
$this->getSeparator() |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($query = $this->getQuery()) |
|
|
|
|
{ |
|
|
|
|
$address .= sprintf( |
|
|
|
|
'?%s', |
|
|
|
|
$query |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($fragment = $this->getFragment()) |
|
|
|
|
{ |
|
|
|
|
$address .= sprintf( |
|
|
|
|
'#%s', |
|
|
|
|
$fragment |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $address; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function absolute( |
|
|
|
|
\Yggverse\Net\Address $address |
|
|
|
|
): string |
|
|
|
|
{ |
|
|
|
|
// @TODO |
|
|
|
|
if ($address->isAbsolute()) |
|
|
|
|
{ |
|
|
|
|
return $address->get(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$address->setScheme( |
|
|
|
|
$this->getScheme() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$address->setUser( |
|
|
|
|
$this->getUser() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$address->setPass( |
|
|
|
|
$this->getPass() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$address->setHost( |
|
|
|
|
$this->getHost() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$address->setPort( |
|
|
|
|
$this->getPort() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return ''; // @TODO |
|
|
|
|
} |
|
|
|
|
} |