diff --git a/src/Uri.php b/src/Uri.php index 28e6070..2dedd01 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -149,7 +149,7 @@ protected function filterScheme($scheme): string } $scheme = str_replace('://', '', strtolower($scheme)); - if (!key_exists($scheme, self::SUPPORTED_SCHEMES)) { + if (!key_exists($scheme, static::SUPPORTED_SCHEMES)) { throw new InvalidArgumentException( 'Uri scheme must be one of: "' . implode('", "', array_keys(static::SUPPORTED_SCHEMES)) . '"' ); diff --git a/tests/UriTest.php b/tests/UriTest.php index 12a09e2..e6e95dd 100644 --- a/tests/UriTest.php +++ b/tests/UriTest.php @@ -31,6 +31,18 @@ public function uriFactory() return new Uri($scheme, $host, $port, $path, $query, $fragment, $user, $password); } + public function testSupportOtherSchemes() + { + $wsUri = new class ('ws', 'example.com') extends Uri { + public const SUPPORTED_SCHEMES = [ + 'ws' => 80, + 'wss' => 443, + ]; + }; + + $this->assertEquals('ws', $wsUri->getScheme()); + } + public function testGetScheme() { $this->assertEquals('https', $this->uriFactory()->getScheme());