Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • AbstractResponseVisitor
  • BodyVisitor
  • HeaderVisitor
  • JsonVisitor
  • ReasonPhraseVisitor
  • StatusCodeVisitor
  • XmlVisitor

Interfaces

  • ResponseVisitorInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Service\Command\LocationVisitor\Response;
 4: 
 5: use Guzzle\Http\Message\Response;
 6: use Guzzle\Service\Description\Parameter;
 7: use Guzzle\Service\Command\CommandInterface;
 8: 
 9: /**
10:  * Location visitor used to add a particular header of a response to a key in the result
11:  */
12: class HeaderVisitor extends AbstractResponseVisitor
13: {
14:     /**
15:      * {@inheritdoc}
16:      */
17:     public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context =  null)
18:     {
19:         if ($param->getType() == 'object' && $param->getAdditionalProperties() instanceof Parameter) {
20:             $this->processPrefixedHeaders($response, $param, $value);
21:         } else {
22:             $value[$param->getName()] = $param->filter((string) $response->getHeader($param->getWireName()));
23:         }
24:     }
25: 
26:     /**
27:      * Process a prefixed header array
28:      *
29:      * @param Response  $response Response that contains the headers
30:      * @param Parameter $param    Parameter object
31:      * @param array     $value    Value response array to modify
32:      */
33:     protected function processPrefixedHeaders(Response $response, Parameter $param, &$value)
34:     {
35:         // Grab prefixed headers that should be placed into an array with the prefix stripped
36:         if ($prefix = $param->getSentAs()) {
37:             $container = $param->getName();
38:             $len = strlen($prefix);
39:             // Find all matching headers and place them into the containing element
40:             foreach ($response->getHeaders() as $key => $header) {
41:                 if (stripos($key, $prefix) === 0) {
42:                     // Account for multi-value headers
43:                     $value[$container][substr($key, $len)] = count($header) == 1 ? end($header) : $header;
44:                 }
45:             }
46:         }
47:     }
48: }
49: 
php-coveralls API documentation generated by ApiGen 2.8.0