/** * Returns an object to be used by `json_encode` to serialize objects of this class. * * @return object * * @see http://php.net/manual/en/jsonserializable.jsonserialize.php JsonSerializable::jsonSerialize * * @api */ public function jsonSerialize() { $obj = parent::jsonSerialize(); $obj->details->image = (object) ['width' => $this->width, 'height' => $this->height]; return $obj; }