Skip to content

Commit

Permalink
PublishedAt can be null or string
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasvts committed Sep 19, 2022
1 parent 2f7d64c commit 397f693
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Interfaces/Consumer/GoAssistedConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ public function actionIndex(): void
throw new InvalidArguments(sprintf('Invalid body. Must be string. Got: %s', gettype($body)));
}

$publishedAt = $_SERVER['HTTP_PUBLISHED_AT'];
if (!is_int($publishedAt)) {
throw new InvalidArguments(sprintf('Invalid published at. Must be int. Got: %s', gettype($publishedAt)));
}
$publishedAt = $_SERVER['HTTP_PUBLISHED_AT'] ?? null;

echo $this->parseRequest(
$this,
Expand All @@ -78,7 +75,7 @@ public function actionIndex(): void
* @param string $methodName
* @param string $routingKey
* @param string $body
* @param int|null $publishedAt
* @param string|null $publishedAt
*
* @throws InvalidArguments
* @throws JsonException
Expand All @@ -92,7 +89,7 @@ final public function parseRequest(
string $methodName,
string $routingKey,
string $body,
?int $publishedAt = null
?string $publishedAt = null
): string {
if (!$methodName) {
return '';
Expand All @@ -112,7 +109,7 @@ final public function parseRequest(
if ($publishedAt !== null) {
$params[] = $publishedAt;
} else {
$params[] = $this->clock->timestamp();
$params[] = $this->clock->dateTimeWithMicroTime();
}
}

Expand Down

0 comments on commit 397f693

Please sign in to comment.