identifier = $identifier; $this->variables = $variables; } /** * @param $callIdTest * @param $deliveryResultIdentifier * @param $testIdentifier * @param \taoResultServer_models_classes_Variable[] $testVariables * * @return VariableStorableCollection */ public static function createTestVariableCollection($callIdTest, $deliveryResultIdentifier, $testIdentifier, array $testVariables) { $storableVariables = []; foreach ($testVariables as $testVariable) { if (!($testVariable->isSetEpoch())) { $testVariable->setEpoch(microtime()); } $storableVariables[] = new TestVariableStorable($deliveryResultIdentifier, $testIdentifier, $testVariable, $callIdTest); } return new self($callIdTest, $storableVariables); } /** * @param $callIdItem * @param $item * @param $deliveryResultIdentifier * @param $testIdentifier * @param \taoResultServer_models_classes_Variable[] $testVariables * * @return VariableStorableCollection */ public static function createItemVariableCollection($callIdItem, $item, $deliveryResultIdentifier, $testIdentifier, array $testVariables) { $storableVariables = []; foreach ($testVariables as $testVariable) { if (!($testVariable->isSetEpoch())) { $testVariable->setEpoch(microtime()); } $storableVariables[] = new ItemVariableStorable($deliveryResultIdentifier, $testIdentifier, $testVariable, $item, $callIdItem); } return new self($callIdItem, $storableVariables); } /** * @param $deliveryResultIdentifier * @param array $variables * @return VariableStorableCollection */ public static function createFromArray($deliveryResultIdentifier, array $variables) { $storableVariables = []; foreach ($variables as $variable) { $variable = json_decode($variable, true); if (isset($variable['callIdTest'])) { $variableObj = TestVariableStorable::createFromArray($variable); } elseif (isset($variable['callIdItem'])) { $variableObj = ItemVariableStorable::createFromArray($variable); } else { continue; } $storableVariables[] = $variableObj; } return new self($deliveryResultIdentifier, $storableVariables); } /** * @return string */ public function getIdentifier() { return $this->identifier; } /** * @return array */ public function toStorableArray() { $data = []; foreach ($this->variables as $variable) { $data[$variable->getIdentifier()] = json_encode([ $variable ]); } return $data; } }