本文整理汇总了PHP中Guzzle\Common\Collection::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::getAll方法的具体用法?PHP Collection::getAll怎么用?PHP Collection::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Common\Collection
的用法示例。
在下文中一共展示了Collection::getAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defaultMissingFunction
/**
* Default method to execute when credentials are not specified
*
* @param Collection $config Config options
*
* @return CredentialsInterface
*/
protected function defaultMissingFunction(Collection $config)
{
if ($config->get(Options::KEY) && $config->get(Options::SECRET)) {
// Credentials were not provided, so create them using keys
return Credentials::factory($config->getAll());
}
// Attempt to get credentials from the EC2 instance profile server
return new RefreshableInstanceProfileCredentials(new Credentials('', '', '', 1));
}
示例2: factory
/**
* Create a Cookie by parsing a Cookie HTTP header
*
* @param string $cookieString Cookie HTTP header
*
* @return Cookie
*/
public static function factory($cookieString)
{
$data = new Collection();
if ($cookieString) {
foreach (explode(';', $cookieString) as $kvp) {
$parts = explode('=', $kvp, 2);
$key = urldecode(trim($parts[0]));
$value = isset($parts[1]) ? trim($parts[1]) : '';
$data->add($key, urldecode($value));
}
}
return new static($data->getAll());
}
示例3: testOverwriteWithTraversable
public function testOverwriteWithTraversable()
{
$c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
$b = new Collection(array('foo' => 10, 'bar' => 300));
$c->overwriteWith($b->getIterator());
$this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->getAll());
}
示例4: testCanReplaceAllData
/**
* @covers Guzzle\Common\Collection::replace
*/
public function testCanReplaceAllData()
{
$this->assertSame($this->coll, $this->coll->replace(array('a' => '123')));
$this->assertEquals(array('a' => '123'), $this->coll->getAll());
}
示例5: parseMessage
/**
* {@inheritdoc}
*/
public function parseMessage($message)
{
if (!$message) {
return false;
}
$headers = new Collection();
$scheme = $host = $body = $method = $user = $pass = $query = $port = $version = $protocol = '';
$path = '/';
// Inspired by https://github.com/kriswallsmith/Buzz/blob/message-interfaces/lib/Buzz/Message/Parser/Parser.php#L16
$lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
for ($i = 0, $c = count($lines); $i < $c; $i += 2) {
$line = $lines[$i];
// If two line breaks were encountered, then this is the body
if (empty($line)) {
$body = implode('', array_slice($lines, $i + 2));
break;
}
// Parse message headers
if (!$method) {
list($method, $path, $proto) = explode(' ', $line);
$method = strtoupper($method);
list($protocol, $version) = explode('/', strtoupper($proto));
$scheme = 'http';
} else {
if (strpos($line, ':')) {
list($key, $value) = explode(':', $line, 2);
$key = trim($key);
// Normalize standard HTTP headers
if (in_array(strtolower($key), static::$requestHeaders)) {
$key = str_replace(' ', '-', ucwords(str_replace('-', ' ', $key)));
}
// Headers are case insensitive
$headers->add($key, trim($value));
}
}
}
// Check for the Host header
if (isset($headers['Host'])) {
$host = $headers['Host'];
}
if (strpos($host, ':')) {
list($host, $port) = array_map('trim', explode(':', $host));
if ($port == 443) {
$scheme = 'https';
}
} else {
$port = '';
}
// Check for basic authorization
$auth = isset($headers['Authorization']) ? $headers['Authorization'] : '';
if ($auth) {
list($type, $data) = explode(' ', $auth);
if (strtolower($type) == 'basic') {
$data = base64_decode($data);
list($user, $pass) = explode(':', $data);
}
}
// Check if a query is present
$qpos = strpos($path, '?');
if ($qpos) {
$query = substr($path, $qpos);
$path = substr($path, 0, $qpos);
}
return array('method' => $method, 'protocol' => $protocol, 'protocol_version' => $version, 'parts' => array('scheme' => $scheme, 'host' => $host, 'port' => $port, 'user' => $user, 'pass' => $pass, 'path' => $path, 'query' => $query), 'headers' => $headers->getAll(), 'body' => $body);
}
示例6: getCookies
/**
* {@inheritdoc}
*/
public function getCookies()
{
$cookieData = new Collection();
if ($cookies = $this->getHeader('Cookie')) {
foreach ($cookies as $cookie) {
$parts = explode('=', $cookie, 2);
$cookieData->add($parts[0], isset($parts[1]) ? $parts[1] : '');
}
}
return $cookieData->getAll();
}
示例7: testOverridesSettings
public function testOverridesSettings()
{
$c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
$c->overwriteWith(array('foo' => 10, 'bar' => 300));
$this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->getAll());
}