예제 #1
0
 private function stockHeader(Parameter $schema, $paramValue, array &$options)
 {
     $paramName = $schema->getName();
     if (stripos($paramName, 'metadata') !== false) {
         return $this->stockMetadataHeader($schema, $paramValue, $options);
     }
     $options['headers'] += is_scalar($paramValue) ? [$schema->getPrefixedName() => $paramValue] : [];
 }
예제 #2
0
 /**
  * A generic method that will populate a JSON structure with a value according to a schema. It
  * supports multiple types and will delegate accordingly.
  *
  * @param Parameter $param     The schema that defines how the JSON field is being populated
  * @param mixed     $userValue The user value that is populating a JSON field
  * @param array     $json      The existing JSON structure that will be populated
  *
  * @return array
  */
 public function stockJson(Parameter $param, $userValue, array $json) : array
 {
     if ($param->isArray()) {
         $userValue = $this->stockArrayJson($param, $userValue);
     } elseif ($param->isObject()) {
         $userValue = $this->stockObjectJson($param, $this->serializeObjectValue($userValue));
     }
     // Populate the final value
     return $this->stockValue($param, $userValue, $json);
 }
예제 #3
0
 /**
  * Retrieves the child parameter for an object parameter.
  *
  * @param string $name The name of the child property
  *
  * @return null|Parameter
  */
 public function getProperty(string $name)
 {
     if ($this->properties instanceof Parameter) {
         $this->properties->setName($name);
         return $this->properties;
     }
     return isset($this->properties[$name]) ? $this->properties[$name] : null;
 }
예제 #4
0
 /**
  * @expectedException \Exception
  */
 public function test_exception_is_thrown_when_value_is_not_in_enum_list()
 {
     $data = $this->data;
     $data['enum'] = ['foo'];
     $param = new Parameter($data);
     $param->validate('blah');
 }