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] : []; }
private static function parseHeader(Parameter $param, $name, $value) { if ($name == 'metadata' || $name == 'removeMetadata') { $headers = []; foreach ($value as $key => $keyVal) { $schema = $param->getItemSchema() ?: new Parameter(['prefix' => $param->getPrefix(), 'name' => $key]); $headers += self::parseHeader($schema, $key, $keyVal); } return $headers; } return is_string($value) || is_numeric($value) ? [$param->getPrefix() . $param->getName() => $value] : []; }
/** * Populates the actual value into a JSON field, i.e. it has reached the end of the line and no * further nesting is required. * * @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|mixed */ private function stockValue(Parameter $param, $userValue, array $json) : array { $name = $param->getName(); if ($path = $param->getPath()) { $jsonPath = new JsonPath($json); $jsonPath->set(sprintf("%s.%s", $path, $name), $userValue); $json = $jsonPath->getStructure(); } elseif ($name) { $json[$name] = $userValue; } else { $json[] = $userValue; } return $json; }
public function test_it_should_use_sentAs_alias_for_name_if_one_is_set() { $data = $this->data + ['sentAs' => 'foo']; $param = new Parameter($data); $this->assertEquals($data['sentAs'], $param->getName()); }