-
Notifications
You must be signed in to change notification settings - Fork 0
Initial implementation #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
When merging please do |
composer.json
Outdated
| @@ -0,0 +1,28 @@ | |||
| { | |||
| "name": "lendable/json", | |||
| "description": "Json Abstraction", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "description": "Json Abstraction", | |
| "description": "JSON serializer/deserializer with an OOP interface", |
lib/JsonDeserializeFailed.php
Outdated
|
|
||
| namespace Lendable\Json; | ||
|
|
||
| final class JsonDeserializeFailed extends \RuntimeException implements JsonFailure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: JsonDeserializationFailed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking, do we even need the Json prefix at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah fair enough, namespace exists
lib/JsonSerializeFailed.php
Outdated
|
|
||
| namespace Lendable\Json; | ||
|
|
||
| final class JsonSerializeFailed extends \RuntimeException implements JsonFailure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JsonSerializationFailed ?
lib/JsonSerializer.php
Outdated
| return $serialized; | ||
| } | ||
|
|
||
| public function deserialize(string $json): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a safe return type, to make it safe we'd need to A) document that only objects/arrays are supported (i'm fine with that) and B) check the result after json_decode() and throw another exception (InvalidDeserializedData?) if not an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, along with other stuff
lib/Serializer.php
Outdated
|
|
||
| namespace Lendable\Json; | ||
|
|
||
| interface Serializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need this unless you can convince me of it's value :)
|
LMK thoughts on above suggestions, doesn't have to be done |
Co-Authored-By: kunicmarko20 <kunicmarko20@gmail.com>
lib/Serializer.php
Outdated
| final class Serializer | ||
| { | ||
| /** | ||
| * @param mixed $data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can now be dropped
|
So, can we merge this? |
No description provided.