Skip to content

Commit

Permalink
Implement JsonSerializable on JsonModel
Browse files Browse the repository at this point in the history
  • Loading branch information
kristen-kagei committed Jan 16, 2020
1 parent 12527a5 commit e17c68b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Models/JsonModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace NPR\One\Models;

use JsonSerializable;

/**
* A thin abstraction to aide in transforming raw JSON into a model, yet allowing it to be re-encoded as JSON when
* stringified.
*
* @package NPR\One\Models
*/
abstract class JsonModel
abstract class JsonModel implements JsonSerializable
{
/** @var \stdClass - the original json used to construct this model, useful for debugging
* @internal */
Expand All @@ -30,6 +31,14 @@ public function __construct($json)
}
}

/**
* JSON Serialize the original JSON object
*/
public function jsonSerialize()
{
return $this->originalJsonObject;
}

/**
* Re-encodes the original JSON model as a string and returns it.
*
Expand Down

0 comments on commit e17c68b

Please sign in to comment.