Skip to content

Commit

Permalink
docs: fix throw Uncastable in quickstart Local Cast example;
Browse files Browse the repository at this point in the history
closes #685;
  • Loading branch information
olexoliinyk0 authored Mar 13, 2024
1 parent 163cc5b commit 4746de6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ use Str;

class ImageCast implements Cast
{
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): Image
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): Image|Uncastable
{
// Scenario A
if ($value instanceof UploadedFile) {
Expand All @@ -330,13 +330,13 @@ class ImageCast implements Cast
);
}

throw Uncastable::create();
return Uncastable::create();
}
}

```

Ultimately, we throw `Uncastable`, telling the package to try other casts (if available) because this cast cannot cast the value.
Ultimately, we return `Uncastable`, telling the package to try other casts (if available) because this cast cannot cast the value.

The last thing we need to do is add the cast to our property. We use the `WithCast` attribute for this:

Expand Down

0 comments on commit 4746de6

Please sign in to comment.