-
-
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.
[minor] add named PathOutsideRoot exception
- Loading branch information
Showing
3 changed files
with
15 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Zenstruck\Uri\Exception; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
final class PathOutsideRoot extends \RuntimeException | ||
{ | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
namespace Zenstruck\Uri; | ||
|
||
use Zenstruck\Uri\Exception\PathOutsideRoot; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
|
@@ -61,7 +63,7 @@ public function absolute(): string | |
|
||
switch (true) { | ||
case '..' === $segment && empty($stack): | ||
throw new \RuntimeException(\sprintf('Cannot resolve absolute path for "%s". It is outside of the root.', $this->toString())); | ||
throw new PathOutsideRoot(\sprintf('Cannot resolve absolute path for "%s". It is outside of the root.', $this->toString())); | ||
case '..' === $segment: | ||
\array_pop($stack); | ||
|
||
|
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