Skip to content

Conversation

@kunicmarko20
Copy link
Member

No description provided.

@kunicmarko20
Copy link
Member Author

When merging please do Squash and merge. Thank you

composer.json Outdated
@@ -0,0 +1,28 @@
{
"name": "lendable/json",
"description": "Json Abstraction",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "Json Abstraction",
"description": "JSON serializer/deserializer with an OOP interface",


namespace Lendable\Json;

final class JsonDeserializeFailed extends \RuntimeException implements JsonFailure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: JsonDeserializationFailed ?

Copy link
Member Author

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?

Copy link
Contributor

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


namespace Lendable\Json;

final class JsonSerializeFailed extends \RuntimeException implements JsonFailure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JsonSerializationFailed ?

return $serialized;
}

public function deserialize(string $json): array
Copy link
Contributor

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.

Copy link
Member Author

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


namespace Lendable\Json;

interface Serializer
Copy link
Contributor

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 :)

@ben-challis
Copy link
Contributor

LMK thoughts on above suggestions, doesn't have to be done

ben-challis and others added 2 commits November 27, 2018 12:04
final class Serializer
{
/**
* @param mixed $data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can now be dropped

@kunicmarko20
Copy link
Member Author

So, can we merge this?

@ben-challis ben-challis merged commit 1b61f76 into master Nov 27, 2018
@ben-challis ben-challis deleted the lib branch November 27, 2018 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants