-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate(documentator): `LastDragon_ru\LaraASP\Documentator\Utils\Pa…
…th` (please use `LastDragon_ru\LaraASP\Core\Utils\Path` instead). (#146)
- Loading branch information
1 parent
3e30a97
commit d2c7592
Showing
15 changed files
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Core\Utils; | ||
|
||
use Symfony\Component\Filesystem\Path as SymfonyPath; | ||
|
||
use function dirname; | ||
use function is_file; | ||
|
||
class Path { | ||
public static function getPath(string $root, string $path): string { | ||
$path = static::isRelative($path) | ||
? static::join(static::getDirname($root), $path) | ||
: $path; | ||
$path = static::normalize($path); | ||
|
||
return $path; | ||
} | ||
|
||
public static function getRelativePath(string $root, string $path): string { | ||
$path = static::isRelative($path) | ||
? static::join(static::getDirname($root), $path) | ||
: $path; | ||
$path = SymfonyPath::makeRelative($path, $root); | ||
$path = static::normalize($path); | ||
|
||
return $path; | ||
} | ||
|
||
public static function getDirname(string $path): string { | ||
return static::normalize(is_file($path) ? dirname($path) : $path); | ||
} | ||
|
||
public static function isRelative(string $path): bool { | ||
return SymfonyPath::isRelative(static::normalize($path)); | ||
} | ||
|
||
public static function isAbsolute(string $path): bool { | ||
return SymfonyPath::isAbsolute(static::normalize($path)); | ||
} | ||
|
||
public static function normalize(string $path): string { | ||
return SymfonyPath::canonicalize($path); | ||
} | ||
|
||
public static function join(string ...$paths): string { | ||
return SymfonyPath::join(...$paths); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
packages/documentator/src/Utils/PathTest.php → packages/core/src/Utils/PathTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters