private function processVariant(Variant $variant, \DOMElement $variantEl, array $resultClasses) { $errorEls = $variantEl->query('.//error'); if ($errorEls->length) { $errors = []; foreach ($errorEls as $errorEl) { $error = new Error($errorEl->nodeValue, $errorEl->getAttribute('exception-class'), $errorEl->getAttribute('code'), $errorEl->getAttribute('file'), $errorEl->getAttribute('line'), ''); $errors[] = $error; } $variant->createErrorStack($errors); return; } foreach ($variantEl->query('./iteration') as $iterationEl) { $results = []; foreach ($iterationEl->attributes as $attributeEl) { $name = $attributeEl->name; if (false === strpos($name, '-')) { throw new \RuntimeException(sprintf('Expected attribute name to have a result key prefix, got "%s".', $name)); } $prefix = substr($name, 0, strpos($name, '-')); if (!isset($resultClasses[$prefix])) { throw new \RuntimeException(sprintf('No result class was provided with key "%s" for attribute "%s"', $prefix, $name)); } $suffix = substr($name, strpos($name, '-') + 1); $results[$prefix][str_replace('-', '_', $suffix)] = $attributeEl->value; } $iteration = $variant->createIteration(); foreach ($results as $resultKey => $resultData) { $iteration->setResult(call_user_func_array([$resultClasses[$resultKey], 'fromArray'], [$resultData])); } } // TODO: Serialize statistics .. $variant->computeStats(); }