Implemented JsonSerializable interface for models/records
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user