Skip to content

Commit 0f64f0c

Browse files
author
awu
committed
chore: rename Utils.php to NdJson.php and update method references
1 parent bafe2c5 commit 0f64f0c

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

src/Client.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
namespace Thenativeweb\Eventsourcingdb;
66

77
use DateTimeImmutable;
8-
use Exception;
98
use GuzzleHttp\Client as HttpClient;
10-
use GuzzleHttp\Exception\GuzzleException;
119
use RuntimeException;
12-
use Thenativeweb\Eventsourcingdb\Stream\Utils;
10+
use Thenativeweb\Eventsourcingdb\Stream\NdJson;
1311

1412
final readonly class Client
1513
{
@@ -25,9 +23,6 @@ public function __construct(string $url, string $apiToken)
2523
]);
2624
}
2725

28-
/**
29-
* @throws GuzzleException
30-
*/
3126
public function ping(): void
3227
{
3328
$response = $this->httpClient->get('/api/v1/ping');
@@ -48,9 +43,6 @@ public function ping(): void
4843
}
4944
}
5045

51-
/**
52-
* @throws GuzzleException
53-
*/
5446
public function verifyApiToken(): void
5547
{
5648
$response = $this->httpClient->post(
@@ -78,10 +70,6 @@ public function verifyApiToken(): void
7870
}
7971
}
8072

81-
/**
82-
* @return iterable<CloudEvent>
83-
* @throws Exception|GuzzleException
84-
*/
8573
public function writeEvents(array $events, array $preconditions = []): iterable
8674
{
8775
$requestBody = [
@@ -143,10 +131,6 @@ public function writeEvents(array $events, array $preconditions = []): iterable
143131
}
144132
}
145133

146-
/**
147-
* @return iterable<CloudEvent>
148-
* @throws Exception|GuzzleException
149-
*/
150134
public function readEvents(string $subject, ReadEventsOptions $readEventsOptions): iterable
151135
{
152136
$requestBody = [
@@ -173,7 +157,7 @@ public function readEvents(string $subject, ReadEventsOptions $readEventsOptions
173157
));
174158
}
175159

176-
foreach (Utils::readNdJson($response->getBody()) as $eventLine) {
160+
foreach (NdJson::readStream($response->getBody()) as $eventLine) {
177161
switch ($eventLine->type) {
178162
case 'event':
179163
$cloudEvent = new CloudEvent(
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Psr\Http\Message\StreamInterface;
88
use RuntimeException;
99

10-
final readonly class Utils
10+
final readonly class NdJson
1111
{
1212
public static function readLine(StreamInterface $stream): string
1313
{
@@ -27,10 +27,7 @@ public static function readLine(StreamInterface $stream): string
2727
return $buffer;
2828
}
2929

30-
/**
31-
* @return iterable<ReadEventLine>
32-
*/
33-
public static function readNdJson(StreamInterface $stream): iterable
30+
public static function readStream(StreamInterface $stream): iterable
3431
{
3532
while (!$stream->eof()) {
3633
$line = self::readLine($stream);

0 commit comments

Comments
 (0)