本文整理汇总了PHP中Guzzle\Common\Collection::hasKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::hasKey方法的具体用法?PHP Collection::hasKey怎么用?PHP Collection::hasKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Common\Collection
的用法示例。
在下文中一共展示了Collection::hasKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testChecksIfHasKey
public function testChecksIfHasKey()
{
$this->assertFalse($this->coll->hasKey('test'));
$this->coll->add('test', 'value');
$this->assertEquals(true, $this->coll->hasKey('test'));
$this->coll->add('test2', 'value2');
$this->assertEquals(true, $this->coll->hasKey('test'));
$this->assertEquals(true, $this->coll->hasKey('test2'));
$this->assertFalse($this->coll->hasKey('testing'));
$this->assertEquals(false, $this->coll->hasKey('AB-C', 'junk'));
}
示例2: prepareConfig
/**
* Validate and prepare configuration parameters
*
* @param array $config Configuration values to apply.
* @param array $defaults Default parameters
* @param array $required Required parameter names
*
* @return Collection
* @throws InvalidArgumentException if a parameter is missing
*/
public static function prepareConfig(array $config = null, array $defaults = null, array $required = null)
{
$collection = new Collection($defaults);
foreach ((array) $config as $key => $value) {
$collection->set($key, $value);
}
foreach ((array) $required as $key) {
if ($collection->hasKey($key) === false) {
throw new ValidationException("Config must contain a '{$key}' key");
}
}
return $collection;
}
示例3: handleEndpoint
private function handleEndpoint(Collection $config)
{
// Alias "endpoint" with "base_url" for forwards compatibility.
if ($config['endpoint']) {
$config[Options::BASE_URL] = $config['endpoint'];
return;
}
if ($config[Options::BASE_URL]) {
return;
}
$endpoint = call_user_func($config['endpoint_provider'], array('scheme' => $config[Options::SCHEME], 'region' => $config[Options::REGION], 'service' => $config[Options::SERVICE]));
$config[Options::BASE_URL] = $endpoint['endpoint'];
// Set a signature if one was not explicitly provided.
if (!$config->hasKey(Options::SIGNATURE) && isset($endpoint['signatureVersion'])) {
$config->set(Options::SIGNATURE, $endpoint['signatureVersion']);
}
// The the signing region if endpoint rule specifies one.
if (isset($endpoint['credentialScope'])) {
$scope = $endpoint['credentialScope'];
if (isset($scope['region'])) {
$config->set(Options::SIGNATURE_REGION, $scope['region']);
}
}
}
示例4: updateConfigFromDescription
/**
* Update a configuration object from a service description
*
* @param Collection $config Config to update
*
* @return ServiceDescription
* @throws InvalidArgumentException
*/
protected function updateConfigFromDescription(Collection $config)
{
$description = $config->get(Options::SERVICE_DESCRIPTION);
if (!$description instanceof ServiceDescription) {
// Inject the version into the sprintf template if it is a string
if (is_string($description)) {
$description = sprintf($description, $config->get(Options::VERSION));
}
$description = ServiceDescription::factory($description);
$config->set(Options::SERVICE_DESCRIPTION, $description);
}
if (!$config->get(Options::SERVICE)) {
$config->set(Options::SERVICE, $description->getData('endpointPrefix'));
}
if ($iterators = $description->getData('iterators')) {
$this->setIteratorsConfig($iterators);
}
// Make sure a valid region is set
$region = $config->get(Options::REGION);
$global = $description->getData('globalEndpoint');
if (!$global && !$region) {
throw new InvalidArgumentException('A region is required when using ' . $description->getData('serviceFullName'));
} elseif ($global && (!$region || $description->getData('namespace') !== 'S3')) {
$region = 'us-east-1';
$config->set(Options::REGION, 'us-east-1');
}
if (!$config->get(Options::BASE_URL)) {
$endpoint = call_user_func($config->get('endpoint_provider'), array('scheme' => $config->get(Options::SCHEME), 'region' => $region, 'service' => $config->get(Options::SERVICE)));
$config->set(Options::BASE_URL, $endpoint['endpoint']);
// Set a signature if one was not explicitly provided.
if (!$config->hasKey(Options::SIGNATURE) && isset($endpoint['signatureVersion'])) {
$config->set(Options::SIGNATURE, $endpoint['signatureVersion']);
}
}
return $description;
}