Example #1
0
 /**
  * Add the parameters to the bag
  * @param array $parameters
  */
 private function addParameters(array $parameters)
 {
     $this->parameters = new ParameterBag();
     $supportedKeys = Settings::getKeys();
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $method = 'set' . ucfirst(Helper::camelCase($key));
             if (method_exists($this, $method)) {
                 $this->{$method}($value);
             } elseif (in_array($key, $supportedKeys)) {
                 $this->parameters->set($key, $value);
             }
         }
     }
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function initialize(array $parameters = array())
 {
     if (null !== $this->response) {
         throw new RuntimeException('Request cannot be modified after it has been sent!');
     }
     $this->parameters = new ParameterBag();
     $supportedKeys = $this->getSupportedKeys();
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $method = 'set' . ucfirst(Helper::camelCase($key));
             if (method_exists($this, $method)) {
                 $this->{$method}($value);
             } else {
                 if (in_array($key, $supportedKeys)) {
                     $this->parameters->set($key, $value);
                 }
             }
         }
     }
     return $this;
 }
 /**
  * Validate credit card details:
  * - country
  * - email
  * - name
  * - phone.
  */
 protected function validateCreditCardDetails()
 {
     $this->validate('card');
     $card = $this->getCard();
     foreach (array('country', 'email', 'name', 'phone') as $key) {
         $method = 'get' . ucfirst(Helper::camelCase($key));
         if (null === $card->{$method}()) {
             throw new InvalidCreditCardDetailsException("The {$key} parameter is required");
         }
     }
 }
Example #4
0
 public function testCamelCaseAlreadyCorrect()
 {
     $result = Helper::camelCase('testCase');
     $this->assertEquals('testCase', $result);
 }
 public function testCamelCaseWithUppercaseValue()
 {
     $result = Helper::camelCase('TEST_CASE');
     $this->assertEquals('testCase', $result);
 }