Example #1
0
 /**
  * @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;
 }