php-path/src/FilesystemPath.php

25 lines
564 B
PHP
Raw Normal View History

2021-10-31 21:36:41 +00:00
<?php
declare(strict_types=1);
namespace Arokettu\Path;
abstract class FilesystemPath extends AbstractAbsolutePath
{
2021-11-01 01:42:46 +00:00
/**
* @codeCoverageIgnore OS specific
*/
2021-10-31 21:36:41 +00:00
public static function parse(string $path, bool $strict = false): self
{
if (DIRECTORY_SEPARATOR === '\\') {
return new WindowsPath($path, $strict);
}
if (DIRECTORY_SEPARATOR === '/') {
return new UnixPath($path, $strict);
}
throw new \LogicException('Unknown directory separator: ' . DIRECTORY_SEPARATOR);
}
}