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

  • AbstractRequestVisitor
  • BodyVisitor
  • HeaderVisitor
  • JsonVisitor
  • PostFieldVisitor
  • PostFileVisitor
  • QueryVisitor
  • ResponseBodyVisitor
  • XmlVisitor

Interfaces

  • RequestVisitorInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Service\Command\LocationVisitor\Request;
 4: 
 5: use Guzzle\Service\Command\CommandInterface;
 6: use Guzzle\Http\Message\RequestInterface;
 7: use Guzzle\Service\Description\Parameter;
 8: 
 9: /**
10:  * {@inheritdoc}
11:  */
12: abstract class AbstractRequestVisitor implements RequestVisitorInterface
13: {
14:     /**
15:      * {@inheritdoc}
16:      * @codeCoverageIgnore
17:      */
18:     public function after(CommandInterface $command, RequestInterface $request) {}
19: 
20:     /**
21:      * {@inheritdoc}
22:      * @codeCoverageIgnore
23:      */
24:     public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value) {}
25: 
26:     /**
27:      * Prepare (filter and set desired name for request item) the value for request.
28:      *
29:      * @param mixed                                     $value
30:      * @param \Guzzle\Service\Description\Parameter     $param
31:      *
32:      * @return array|mixed
33:      */
34:     protected function prepareValue($value, Parameter $param)
35:     {
36:         return is_array($value)
37:             ? $this->resolveRecursively($value, $param)
38:             : $param->filter($value);
39:     }
40: 
41:     /**
42:      * Map nested parameters into the location_key based parameters
43:      *
44:      * @param array     $value Value to map
45:      * @param Parameter $param Parameter that holds information about the current key
46:      *
47:      * @return array Returns the mapped array
48:      */
49:     protected function resolveRecursively(array $value, Parameter $param)
50:     {
51:         foreach ($value as $name => &$v) {
52:             switch ($param->getType()) {
53:                 case 'object':
54:                     if ($subParam = $param->getProperty($name)) {
55:                         $key = $subParam->getWireName();
56:                         $value[$key] = $this->prepareValue($v, $subParam);
57:                         if ($name != $key) {
58:                             unset($value[$name]);
59:                         }
60:                     } elseif ($param->getAdditionalProperties() instanceof Parameter) {
61:                         $v = $this->prepareValue($v, $param->getAdditionalProperties());
62:                     }
63:                     break;
64:                 case 'array':
65:                     if ($items = $param->getItems()) {
66:                         $v = $this->prepareValue($v, $items);
67:                     }
68:                     break;
69:             }
70:         }
71: 
72:         return $param->filter($value);
73:     }
74: }
75: 
php-coveralls API documentation generated by ApiGen 2.8.0