diff --git a/src/Firebase/Database.php b/src/Firebase/Database.php index 577dd004..cc332129 100644 --- a/src/Firebase/Database.php +++ b/src/Firebase/Database.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Reference; use Kreait\Firebase\Database\RuleSet; use Kreait\Firebase\Database\Transaction; -use Kreait\Firebase\Database\UrlBuilder; use Kreait\Firebase\Exception\InvalidArgumentException; use Psr\Http\Message\UriInterface; @@ -25,7 +24,6 @@ final class Database implements Contract\Database public function __construct( private readonly UriInterface $uri, private readonly ApiClient $client, - private readonly UrlBuilder $urlBuilder, ) { } @@ -38,7 +36,7 @@ public function getReference(?string $path = null): Reference $path = '/'.ltrim($path, '/'); try { - return new Reference($this->uri->withPath($path), $this->client, $this->urlBuilder); + return new Reference($this->uri->withPath($path), $this->client); } catch (\InvalidArgumentException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } diff --git a/src/Firebase/Database/Reference.php b/src/Firebase/Database/Reference.php index 1be30805..ae2d587f 100644 --- a/src/Firebase/Database/Reference.php +++ b/src/Firebase/Database/Reference.php @@ -37,7 +37,6 @@ class Reference implements Stringable public function __construct( UriInterface $uri, private readonly ApiClient $apiClient, - private readonly UrlBuilder $urlBuilder, private readonly Validator $validator = new Validator(), ) { $this->validator->validateUri($uri); @@ -93,7 +92,6 @@ public function getParent(): self return new self( $this->uri->withPath('/'.ltrim($parentPath, '/')), $this->apiClient, - $this->urlBuilder, $this->validator, ); } @@ -103,7 +101,7 @@ public function getParent(): self */ public function getRoot(): self { - return new self($this->uri->withPath('/'), $this->apiClient, $this->urlBuilder, $this->validator); + return new self($this->uri->withPath('/'), $this->apiClient, $this->validator); } /** @@ -122,7 +120,6 @@ public function getChild(string $path): self return new self( $this->uri->withPath($childPath), $this->apiClient, - $this->urlBuilder, $this->validator, ); } catch (\InvalidArgumentException $e) { @@ -326,7 +323,7 @@ public function push($value = null): self $newKey = $this->apiClient->push($this->uri->getPath(), $value); $newPath = sprintf('%s/%s', $this->uri->getPath(), $newKey); - return new self($this->uri->withPath($newPath), $this->apiClient, $this->urlBuilder, $this->validator); + return new self($this->uri->withPath($newPath), $this->apiClient, $this->validator); } /** diff --git a/src/Firebase/Factory.php b/src/Firebase/Factory.php index c408455a..0ddac917 100644 --- a/src/Firebase/Factory.php +++ b/src/Firebase/Factory.php @@ -389,7 +389,6 @@ public function createDatabase(): Contract\Database return new Database( GuzzleUtils::uriFor($databaseUrl), new Database\ApiClient($http, $resourceUrlBuilder), - $resourceUrlBuilder, ); } diff --git a/tests/Unit/Database/ReferenceTest.php b/tests/Unit/Database/ReferenceTest.php index b8b696cc..764550e4 100644 --- a/tests/Unit/Database/ReferenceTest.php +++ b/tests/Unit/Database/ReferenceTest.php @@ -7,7 +7,6 @@ use GuzzleHttp\Psr7\Uri; use Kreait\Firebase\Database\ApiClient; use Kreait\Firebase\Database\Reference; -use Kreait\Firebase\Database\UrlBuilder; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Exception\OutOfRangeException; use Kreait\Firebase\Tests\UnitTestCase; @@ -32,7 +31,6 @@ protected function setUp(): void $this->reference = new Reference( new Uri($url), $this->apiClient, - UrlBuilder::create($url), ); } diff --git a/tests/Unit/Database/UrlBuilderTest.php b/tests/Unit/Database/UrlBuilderTest.php index d1b354ec..1f35b50d 100644 --- a/tests/Unit/Database/UrlBuilderTest.php +++ b/tests/Unit/Database/UrlBuilderTest.php @@ -48,9 +48,7 @@ public static function invalidUrls(): Iterator #[Test] public function getGetUrl(string $baseUrl, string $path, array $queryParams, string $expected): void { - $url = UrlBuilder::create($baseUrl)->getUrl($path, $queryParams); - - $this->assertSame($expected, $url); + $this->assertSame($expected, UrlBuilder::create($baseUrl)->getUrl($path, $queryParams)); } /** @@ -64,9 +62,8 @@ public function getGetUrl(string $baseUrl, string $path, array $queryParams, str public function emulated(string $emulatorHost, string $baseUrl, string $path, array $queryParams, string $expected): void { Util::putenv('FIREBASE_DATABASE_EMULATOR_HOST', $emulatorHost); - $url = UrlBuilder::create($baseUrl)->getUrl($path, $queryParams); - $this->assertSame($expected, $url); + $this->assertSame($expected, UrlBuilder::create($baseUrl)->getUrl($path, $queryParams)); } public static function realUrls(): Iterator diff --git a/tests/Unit/DatabaseTest.php b/tests/Unit/DatabaseTest.php index 9045cd0c..8f8a1f7d 100644 --- a/tests/Unit/DatabaseTest.php +++ b/tests/Unit/DatabaseTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Database; use Kreait\Firebase\Database\ApiClient; use Kreait\Firebase\Database\RuleSet; -use Kreait\Firebase\Database\UrlBuilder; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\Test; @@ -21,16 +20,14 @@ final class DatabaseTest extends UnitTestCase { private ApiClient&MockObject $apiClient; private string $url; - private Uri $uri; private Database $database; protected function setUp(): void { $this->url = 'https://database.firebaseio.com'; - $this->uri = new Uri($this->url); $this->apiClient = $this->createMock(ApiClient::class); - $this->database = new Database($this->uri, $this->apiClient, UrlBuilder::create($this->url)); + $this->database = new Database(new Uri($this->url), $this->apiClient); } #[Test]