Skip to content

Commit

Permalink
Merge pull request #83 from tarfin-labs/WB-291-event-machine-update-m…
Browse files Browse the repository at this point in the history
…achine-cast-set-method-to-handle-uninitialized-machines

WB-291: Update MachineCast set method to handle uninitialized machines
  • Loading branch information
deligoez authored Aug 13, 2024
2 parents cad4773 + 5548e77 commit 97de3d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"property": "none",
"trait_import": "none"
}
}
},
"new_with_parentheses": true
}
}
6 changes: 5 additions & 1 deletion src/Casts/MachineCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ public function get(
* @param TSet|null $value
* @param array<mixed> $attributes
*/
public function set(Model $model, string $key, mixed $value, array $attributes): string
public function set(Model $model, string $key, mixed $value, array $attributes): ?string
{
if ($value === null) {
return null;
}

if (is_string($value)) {
return $value;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
// 1. Arrange
$value = random_int(10, 20);

$multipleWithItselfAction = new class extends ResultBehavior {
$multipleWithItselfAction = new class() extends ResultBehavior {
public function __invoke(EventBehavior $event): int
{
return $event->payload['value'] * $event->payload['value'];
Expand Down

0 comments on commit 97de3d9

Please sign in to comment.