public function __construct($data) { if (is_string($data)) { $this->data = json_decode($data, true); } else { $this->data = $data; } }