當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Collection::hasKey方法代碼示例

本文整理匯總了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'));
 }
開發者ID:alvarobfdev,項目名稱:applog,代碼行數:11,代碼來源:CollectionTest.php

示例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;
 }
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:23,代碼來源:Inspector.php

示例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']);
         }
     }
 }
開發者ID:Trideon,項目名稱:gigolo,代碼行數:24,代碼來源:ClientBuilder.php

示例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;
 }
開發者ID:evanjt,項目名稱:core,代碼行數:44,代碼來源:ClientBuilder.php


注:本文中的Guzzle\Common\Collection::hasKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。