/** * @param Config $config * @throws LogicException * @return array */ public function getDataToArray(Config $config) { $this->setPosId($config->getPosId()); if ($this instanceof NewPaymentRequest) { $this->setPosAuthKey($config->getPosAuthKey()); } $reflection = new ClassType($this); $parameters = array(); $errors = array(); foreach ($reflection->getProperties() as $property) { if ($property->hasAnnotation('var') && $property->getAnnotation('var') == 'bool') { $getterPrefix = 'is'; } else { $getterPrefix = 'get'; } $propertyGetter = $getterPrefix . ucfirst($property->getName()); $value = $this->{$propertyGetter}(); if ($value !== NULL) { $parameters[Strings::camelToUnderdash($property->getName())] = $value; } if ($property->hasAnnotation('required') && $value === NULL) { $errors[] = $property->getName(); } } if (count($errors) > 0) { throw new LogicException('Empty required properties: ' . implode(', ', $errors)); } $parameters['sig'] = $this->getSig($config->getKey1()); return $parameters; }
/** * @throws LogicException * @return string */ private function checkAndGetResponseFormat() { switch ($this->config->getFormat()) { case Config::FORMAT_TXT: case Config::FORMAT_XML: return $this->config->getFormat(); default: throw new LogicException('Not supported response format'); } }