public function __construct($json) { $this->json = $json; $values = json_decode($json, true); $this->count = count($values); foreach ($values as $key => $value) { $this->{$key} = $value; } }