Skip to content
This repository was archived by the owner on Dec 31, 2025. It is now read-only.

Conversation

@caleeli
Copy link

@caleeli caleeli commented Oct 30, 2021

Implements #86

This PR includes:

  • Add method Entity::toArray() to convert an Entity to Array.
  • Add method Entity::toJSON() to convert an Entity to JSON String.
  • Add method EntityCollection::toArray() to convert an EntityCollection to Array.
  • Add method EntityCollection::toJSON() to convert an EntityCollection to JSON String.
  • Add parameter $includeEntities in Entity::toArray() and Entity::toJSON() to include entity-type properties to the result.
  • Add parameter $includeEntities in EntityCollection::toArray() and EntityCollection::toJSON() to include entity-type properties to the result.
  • Unit test for Entity::toArray() and Entity::toJSON()

How to test:

  • Load an Entity. eg. $entity = new User([....])
  • Call to $entity->toArray() to get en Entity converted into Array.
  • Call to $entity->toJSON() to get en Entity converted into JSON String.
  • To include sub-entities like Gender use: $entity->toArray(true) or $entity->toJSON(true)
  • To convert a collection, load a collection. e.g. new EntityCollection('User');
  • Convert it to array: $collection->toArray()
  • Or Convert it to JSON: $collection->toJSON()
  • You could use also $includeEntities=true: $collection->toArray(true) or $collection->toJSON(true)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant