mirror of
https://github.com/YGGverse/net-php.git
synced 2025-01-28 23:54:14 +00:00
add cross-platform separator support
This commit is contained in:
parent
b2e0750d1e
commit
bbdc276db6
@ -16,6 +16,8 @@ class Address
|
|||||||
|
|
||||||
private array $_dirs = [];
|
private array $_dirs = [];
|
||||||
|
|
||||||
|
private string $_separator = '/';
|
||||||
|
|
||||||
public function __construct(?string $address = null)
|
public function __construct(?string $address = null)
|
||||||
{
|
{
|
||||||
if ($address)
|
if ($address)
|
||||||
@ -138,12 +140,17 @@ class Address
|
|||||||
|
|
||||||
public function setPath(string $value): void
|
public function setPath(string $value): void
|
||||||
{
|
{
|
||||||
$this->_path = $value;
|
if (false !== strpos($value, '\\'))
|
||||||
|
{
|
||||||
|
$this->_separator = '\\';
|
||||||
|
}
|
||||||
|
|
||||||
$this->_dirs = explode(
|
$this->_dirs = explode(
|
||||||
'/',
|
$this->_separator,
|
||||||
$value
|
$value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->_path = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDirs(): array
|
public function getDirs(): array
|
||||||
@ -161,6 +168,11 @@ class Address
|
|||||||
$this->_query = $value;
|
$this->_query = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSeparator(): string
|
||||||
|
{
|
||||||
|
return $this->_separator;
|
||||||
|
}
|
||||||
|
|
||||||
public function absolute(string $address): string
|
public function absolute(string $address): string
|
||||||
{
|
{
|
||||||
// @TODO
|
// @TODO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user