public static function fromArray($data) { $capture = new CaptureResponseInformation(); foreach ($data as $key => $value) { if (property_exists(get_class($capture), $key)) { if ($key == "lastCaptureResponse") { $capture->{$key} = CaptureResponse::fromArray($value); } elseif ($key == "errors") { $capture->{$key} = Errors::fromArray($value); } else { $capture->{$key} = $value; } } } return $capture; }