Skip to content

Commit

Permalink
Merge pull request #34 from elbformat/array_support
Browse files Browse the repository at this point in the history
Allow array json values in AbstractDatabaseContext
  • Loading branch information
hgiesenow authored Feb 19, 2024
2 parents 2095f79 + 13c4aaf commit 0fe4977
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v1.5.7
* Feature/Fix: Support json arrays in AbstractDatabaseContext

## v1.5.6
* Feature: Testing with command inputs

Expand Down
4 changes: 4 additions & 0 deletions src/Context/AbstractDatabaseContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ protected function convertAssertionValue(string $value, ?string $type): mixed
}

return match ($type) {
'array' => json_decode($value, false, 512, JSON_THROW_ON_ERROR),
'bool' => 'false' !== $value && '0' !== $value,
'DateTimeInterface', 'DateTime' => new \DateTime($value),
'DateTimeImmutable' => new \DateTimeImmutable($value),
Expand Down Expand Up @@ -268,6 +269,9 @@ protected function printAlternatives(array $data): string
case 'bool' === $type:
$realVal = $realVal ? 'true' : 'false';
break;
case 'array' === $type:
$realVal = json_encode($realVal);
break;
case $realVal instanceof \DateTimeInterface:
$realVal = $realVal->format('c');
break;
Expand Down

0 comments on commit 0fe4977

Please sign in to comment.