Skip to content

Commit

Permalink
feature: implement JsonSerializable in each enum for correct json ser…
Browse files Browse the repository at this point in the history
…ialization
  • Loading branch information
dont-know-php committed Oct 29, 2024
1 parent df084e3 commit f683951
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Enums/CustomCreationMethodType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

namespace Spatie\LaravelData\Enums;

enum CustomCreationMethodType
enum CustomCreationMethodType implements \JsonSerializable
{
case None;
case Object;
case Collection;

public function jsonSerialize(): string
{
return $this->name;
}
}
7 changes: 6 additions & 1 deletion src/Enums/DataCollectableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

namespace Spatie\LaravelData\Enums;

enum DataCollectableType
enum DataCollectableType implements \JsonSerializable
{
case Default;
case Array;
case Collection;
case Paginated;
case CursorPaginated;

public function jsonSerialize(): string
{
return $this->name;
}
}
7 changes: 6 additions & 1 deletion src/Enums/DataTypeKind.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Exception;

enum DataTypeKind
enum DataTypeKind implements \JsonSerializable
{
case Default;
case Array;
Expand Down Expand Up @@ -71,4 +71,9 @@ public function getDataRelatedEquivalent(): self
default => throw new Exception("No equivalent for {$this->name}")
};
}

public function jsonSerialize(): string
{
return $this->name;
}
}

0 comments on commit f683951

Please sign in to comment.