Skip to content

Commit c1b7ec7

Browse files
committed
Rename class to make it clearer
1 parent 9e163bc commit c1b7ec7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/ParserErrorType.php src/APIParserErrorType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Rowbot\URL;
66

7-
enum ParserErrorType
7+
enum APIParserErrorType
88
{
99
case NONE;
1010

src/APIParserResult.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ final class APIParserResult
88
{
99
public readonly ?URLRecord $url;
1010

11-
public readonly ParserErrorType $error;
11+
public readonly APIParserErrorType $error;
1212

13-
public function __construct(?URLRecord $urlRecord, ParserErrorType $error)
13+
public function __construct(?URLRecord $urlRecord, APIParserErrorType $error)
1414
{
1515
$this->url = $urlRecord;
1616
$this->error = $error;

src/URL.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(string|Stringable $url, string|Stringable|null $base
7373
// 1. Let parsedURL be the result of running the API URL parser on url with base, if given.
7474
$parsedURL = self::parseURL($url, $base, $this->logger);
7575

76-
if ($parsedURL->error === ParserErrorType::NONE) {
76+
if ($parsedURL->error === APIParserErrorType::NONE) {
7777
// 3. Initialize this with parsedURL.
7878
assert($parsedURL->url !== null);
7979
self::initializeURL($this, $parsedURL->url);
@@ -83,8 +83,8 @@ public function __construct(string|Stringable $url, string|Stringable|null $base
8383

8484
// 2. If parsedURL is failure, then throw a TypeError.
8585
$message = match ($parsedURL->error) {
86-
ParserErrorType::BASE => 'Invalid base URL',
87-
ParserErrorType::URL => 'Invalid URL'
86+
APIParserErrorType::BASE => 'Invalid base URL',
87+
APIParserErrorType::URL => 'Invalid URL'
8888
};
8989

9090
throw new TypeError($message);
@@ -109,7 +109,7 @@ public static function canParse(string|Stringable $url, string|Stringable|null $
109109
{
110110
$parsedURL = self::parseURL($url, $base);
111111

112-
return $parsedURL->error === ParserErrorType::NONE;
112+
return $parsedURL->error === APIParserErrorType::NONE;
113113
}
114114

115115
public function toString(): string
@@ -161,7 +161,7 @@ private static function parseURL(
161161

162162
// 2.2. If parsedBase is failure, then return failure.
163163
if ($parsedBase === false) {
164-
return new APIParserResult(null, ParserErrorType::BASE);
164+
return new APIParserResult(null, APIParserErrorType::BASE);
165165
}
166166
}
167167

@@ -170,10 +170,10 @@ private static function parseURL(
170170
$parsedURL = $parser->parse(Utf8String::fromUnsafe($stringURL), $parsedBase);
171171

172172
if ($parsedURL === false) {
173-
return new APIParserResult(null, ParserErrorType::URL);
173+
return new APIParserResult(null, APIParserErrorType::URL);
174174
}
175175

176-
return new APIParserResult($parsedURL, ParserErrorType::NONE);
176+
return new APIParserResult($parsedURL, APIParserErrorType::NONE);
177177
}
178178

179179
/**

0 commit comments

Comments
 (0)