diff --git a/src/ParserErrorType.php b/src/APIParserErrorType.php similarity index 81% rename from src/ParserErrorType.php rename to src/APIParserErrorType.php index 26bfc46..91e7f11 100644 --- a/src/ParserErrorType.php +++ b/src/APIParserErrorType.php @@ -4,7 +4,7 @@ namespace Rowbot\URL; -enum ParserErrorType +enum APIParserErrorType { case NONE; diff --git a/src/APIParserResult.php b/src/APIParserResult.php index ddf7b14..056cb62 100644 --- a/src/APIParserResult.php +++ b/src/APIParserResult.php @@ -8,9 +8,9 @@ final class APIParserResult { public readonly ?URLRecord $url; - public readonly ParserErrorType $error; + public readonly APIParserErrorType $error; - public function __construct(?URLRecord $urlRecord, ParserErrorType $error) + public function __construct(?URLRecord $urlRecord, APIParserErrorType $error) { $this->url = $urlRecord; $this->error = $error; diff --git a/src/URL.php b/src/URL.php index 4513e14..2903554 100644 --- a/src/URL.php +++ b/src/URL.php @@ -73,7 +73,7 @@ public function __construct(string|Stringable $url, string|Stringable|null $base // 1. Let parsedURL be the result of running the API URL parser on url with base, if given. $parsedURL = self::parseURL($url, $base, $this->logger); - if ($parsedURL->error === ParserErrorType::NONE) { + if ($parsedURL->error === APIParserErrorType::NONE) { // 3. Initialize this with parsedURL. assert($parsedURL->url !== null); self::initializeURL($this, $parsedURL->url); @@ -83,8 +83,8 @@ public function __construct(string|Stringable $url, string|Stringable|null $base // 2. If parsedURL is failure, then throw a TypeError. $message = match ($parsedURL->error) { - ParserErrorType::BASE => 'Invalid base URL', - ParserErrorType::URL => 'Invalid URL' + APIParserErrorType::BASE => 'Invalid base URL', + APIParserErrorType::URL => 'Invalid URL' }; throw new TypeError($message); @@ -109,7 +109,7 @@ public static function canParse(string|Stringable $url, string|Stringable|null $ { $parsedURL = self::parseURL($url, $base); - return $parsedURL->error === ParserErrorType::NONE; + return $parsedURL->error === APIParserErrorType::NONE; } public function toString(): string @@ -161,7 +161,7 @@ private static function parseURL( // 2.2. If parsedBase is failure, then return failure. if ($parsedBase === false) { - return new APIParserResult(null, ParserErrorType::BASE); + return new APIParserResult(null, APIParserErrorType::BASE); } } @@ -170,10 +170,10 @@ private static function parseURL( $parsedURL = $parser->parse(Utf8String::fromUnsafe($stringURL), $parsedBase); if ($parsedURL === false) { - return new APIParserResult(null, ParserErrorType::URL); + return new APIParserResult(null, APIParserErrorType::URL); } - return new APIParserResult($parsedURL, ParserErrorType::NONE); + return new APIParserResult($parsedURL, APIParserErrorType::NONE); } /**