From bbdc276db67fe3e475feb9e2d46b3a492d445dc6 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 5 Apr 2024 10:10:19 +0300 Subject: [PATCH] add cross-platform separator support --- src/Address.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Address.php b/src/Address.php index 065f9a4..1e9b3ea 100644 --- a/src/Address.php +++ b/src/Address.php @@ -16,6 +16,8 @@ class Address private array $_dirs = []; + private string $_separator = '/'; + public function __construct(?string $address = null) { if ($address) @@ -138,12 +140,17 @@ class Address public function setPath(string $value): void { - $this->_path = $value; + if (false !== strpos($value, '\\')) + { + $this->_separator = '\\'; + } $this->_dirs = explode( - '/', + $this->_separator, $value ); + + $this->_path = $value; } public function getDirs(): array @@ -161,6 +168,11 @@ class Address $this->_query = $value; } + public function getSeparator(): string + { + return $this->_separator; + } + public function absolute(string $address): string { // @TODO