Implemented JsonSerializable interface for models/records

This commit is contained in:
Gregory Oschwald
2013-10-26 14:13:56 -07:00
parent 7fa971aef8
commit 569043cb8f
4 changed files with 47 additions and 3 deletions
+6 -1
View File
@@ -33,7 +33,7 @@ namespace GeoIp2\Model;
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
* requested IP address.
*/
class Country
class Country implements \JsonSerializable
{
private $continent;
private $country;
@@ -92,4 +92,9 @@ class Country
throw new \RuntimeException("Unknown attribute: $attr");
}
public function jsonSerialize()
{
return $this->raw;
}
}
+6 -1
View File
@@ -2,7 +2,7 @@
namespace GeoIp2\Record;
abstract class AbstractRecord
abstract class AbstractRecord implements \JsonSerializable
{
private $record;
@@ -31,4 +31,9 @@ abstract class AbstractRecord
throw new \RuntimeException("Unknown attribute: $attr");
}
}
public function jsonSerialize()
{
return $this->record;
}
}