Group params in a bean

@param       $method
@param array $params

@return array
961210
public function mergeParams($method, Array $params = [])
    {
        $newParams = [];
        $preparedParams = $this->defaultParams;
        $preparedParams['bean'] = $params;

        $newParams[$method] = $preparedParams;

        return $newParams;
    }
727786
private function getUrlToOldApi($method, array $params, $format)
    {
        $queryString = sprintf(
            '?apikey=%s&format=%s&method=%s%s',
            $this->getApiKey(),
            $format,
            $method,
            $this->paramsQueryStringBuilder($params)
        );

        return sprintf(
            $this::API_URL,
            $this->getDc(),
            $this->getApiVersion(),
            $queryString
        );
    }
1120136
public function get($method, array $params, array $options = array())
    {
        $this->parseOptions($options);

        $params = array_merge($params, $this->apiKeys);

        $response = $this->httpAdapter->getContent(
            sprintf(self::API_ENDPOINT, $this->scheme, $this->outputFormat, $method .'?'. http_build_query($params)),
            $this->headers
        );

        return $this->responseHandler($response);
    }
792247
public function parameterize($method)
    {
        $parameterArray = array();
        switch ($method) {
            case 'create':
                if (!is_null($this->getPreauthorization())) {
                    $parameterArray['preauthorization'] = $this->getPreauthorization();
                } elseif (!is_null($this->getPayment())) {
                    $parameterArray['payment'] = $this->getPayment();
                } else {
                    $parameterArray['token'] = $this->getToken();
                }
                $parameterArray['amount'] = $this->getAmount();
                $parameterArray['currency'] = $this->getCurrency();
                $parameterArray['description'] = $this->getDescription();
                $parameterArray['client'] = $this->getClient();
                if (!is_null($this->getFeeAmount())) {
                    $parameterArray['fee_amount'] = $this->getFeeAmount();
                }
                if (!is_null($this->getFeePayment())) {
                    $parameterArray['fee_payment'] = $this->getFeePayment();
                }
                if (!is_null($this->getFeeCurrency())) {
                    $parameterArray['fee_currency'] = $this->getFeeCurrency();
                }
                if(!is_null($this->getSource())) {
                    $parameterArray['source'] = $this->getSource();
                }
                if(!is_null($this->getShippingAddress())) {
                    $parameterArray['shipping_address'] = $this->getShippingAddress();
                }
                if(!is_null($this->getBillingAddress())) {
                    $parameterArray['billing_address'] = $this->getBillingAddress();
                }
                if(!is_null($this->getItems())) {
                    $parameterArray['items'] = $this->getItems();
                }
                if(!is_null($this->getShippingAmount())) {
                    $parameterArray['shipping_amount'] = $this->getShippingAmount();
                }
                if(!is_null($this->getHandlingAmount())) {
                    $parameterArray['handling_amount'] = $this->getHandlingAmount();
                }
                if (!is_null($this->getMandateReference())) {
                    $parameterArray['mandate_reference'] = $this->getMandateReference();
                }
                if(!is_null($this->getShippingAddress())) {
                    $parameterArray['shipping_address'] = $this->getShippingAddress();
                }
                if(!is_null($this->getBillingAddress())) {
                    $parameterArray['billing_address'] = $this->getBillingAddress();
                }
                break;
            case 'update':
                $parameterArray['description'] = $this->getDescription();
                break;
            case 'getAll':
                $parameterArray = $this->getFilter();
                break;
            case 'getOne':
                $parameterArray['count'] = 1;
                $parameterArray['offset'] = 0;
                break;
            case 'delete':
                break;
        }

        return $parameterArray;
    }
789304
public function request($method, array $params) {
        // invariable parameters:
        $params['login'] = $this->_login;
        $params['apiKey'] = $this->_apiKey;
        $params['format'] = 'json'; 
        $params = http_build_query($params);

        $url = self::BITLY_API_URL.$method.'?'.$params;
        $response = $this->getHttpClient()
                         ->setMethod(Zend_Http_Client::GET)
                         ->setUri($url)
                         ->request()
        ;
        return Zend_Json::decode($response->getBody());
    }
1084459
public function silentRequest($method, array $params = []) {
    $response = NULL;

    if (!method_exists($this, $method)) {
      throw new \InvalidArgumentException("Method {$method} doesn't exist.");
    }

    $this->turnRouteEventsOff();

    try {
      $response = call_user_func_array([$this, $method], $params);
    }
    catch (\Exception $e) {
      $mesg = sprintf(
        'Silent exception during %s request: (%d) - %s',
        $method,
        $e->getCode(),
        $e->getMessage()
      );

      $this->logger->error($mesg);
    }

    $this->turnRouteEventsOn();

    return $response;
  }
541326
public function call($method, $params=[]) {
    $header = $this->generateWSSecurityHeader($this->user, $this->password);
    $response = $this->__soapCall($method, sizeof($params) > 0 ? [$params] : [], null, $header);
    // in document/literal style the "return" parameter holds the result
    return property_exists($response, 'return') ? $response->return : $response;
  }
1370117
protected function buildRequests($method, $urls, $params = [])
    {
        $reqs = [];
        foreach ($urls as $key => $url) {
            $reqs[$key] = $this->buildRequest($method, $url, $params);
        }
        return $reqs;
    }
862229
public static function __callstatic($method, $params) {

    if ($method == 'map') {
        $maps = array_map('strtoupper', $params[0]);
        $uri = strpos($params[1], '/') === 0 ? $params[1] : '/' . $params[1];
        $callback = $params[2];
    } else {
        $maps = null;
        $uri = strpos($params[0], '/') === 0 ? $params[0] : '/' . $params[0];
        $callback = $params[1];
    }

    array_push(self::$maps, $maps);
    array_push(self::$routes, $uri);
    array_push(self::$methods, strtoupper($method));
    array_push(self::$callbacks, $callback);
  }
1059858
private function api($method, $params) 
	{
    
		$basic = array(
		  'method'      => $method,
		  'appid'       => $this->appid,
		  'key'         => $this->key,
		  'path'        => $this->path,
		  'user_ip'     => $_SERVER['REMOTE_ADDR'],
		  'language'    => $this->language,
		  'platform'    => 'php'
		);

		return $this->call(array_merge(isset($params[0]) ? $params[0] : $params, $basic));
	}
713743
public function method(string $method, string $uriPath, callable $handler, array $parameters = []): GroupInterface
    {
        list($middleware, $configurators, $requestFactory, $useGroupFactory, $name) =
            $this->normalizeRouteParameters($parameters);

        $uriPath = $this->normalizeUri($uriPath, $this->hasTrailSlash());

        $route = $this->createRoute($this, $method, $uriPath, $handler)
            ->setUseGroupRequestFactory($useGroupFactory)
            ->setRequestFactory($requestFactory)
            ->setConfigurators($configurators)
            ->setMiddleware($middleware)
            ->setName($name);

        return $this->addRoute($route);
    }
1177136
protected function getCallParams($controller, $method, $params)
		{
			// variables
			$values     = is_array($params) ? $params : explode('/', $params);
			$ref        = new ReflectionMethod($controller, $method);
			$params     = $ref->getParameters();
			$args       = [];
	
			// map route segments to the method's parameters
			foreach ($params as /** @var \ReflectionParameter */ $param)
			{
				// parse signature [match, optional, type, name, default]
				preg_match('/<(required|optional)> (?:([\\\\a-z\d_]+) )?(?:\\$(\w+))(?: = (\S+))?/i', (string)$param, $matches);
	
				// assign untyped segments
				if ($matches[2] == null)
				{
					$args[$matches[3]] = array_shift($values);
				}
			}
	
			// append any remaining values
			return array_merge($args, $values);
		}
168667
protected static function _generateParameters($method)
    {
        $params = [];
        foreach ($method->getParameters() as $num => $parameter) {
            $name = $parameter->getName();
            $name = ($name && $name !== '...') ? $name : 'param' . $num;
            $params[] = "\${$name}";
        }
        return join(', ', $params);
    }
1028639
private function getArgs(string $method) : array
    {
        if (self::request()->getMethod() == 'POST') {
            $data = file_get_contents('php://input');

            // hack for multipart form
            if (!$data) {
                $data = http_build_query($_POST);
            }
        } else {
            $data = self::request()->getUri()->getQuerystring();
        }

        if (self::request()->getMethod() == 'POST' &&
            self::request()->getHeader('Content-Encoding') == 'gzip') {
            $data = gzdecode($data);
        }

        $requestData = $data ? $this->getRequestData($data) : [];

        $return = [];

        /* @var $parametersDefinition Param[] */
        $parametersDefinition = $this->reflectionMethod[$method]->getParam(Definition::PARAM);

        /* @var $parameter \ReflectionParameter */
        foreach ($this->reflectionMethod[$method]->getParameters() as $i => $parameter) {
            $parameterName = $parameter->getName();

            $value = isset($requestData[$parameterName]) ? $requestData[$parameterName] : null;

            if (is_null($value) && !$parameter->isOptional()) {
                throw new ResponseCode("Missing required parameters '$parameterName'", 422);
            }

            if (!isset($parametersDefinition[$i])) {
                throw new \Exception(sprintf(
                    "Missing phpdoc on param '%s' for method '%s:%s'",
                    $parameterName,
                    get_class($this),
                    $method
                ));
            }

            if ($parametersDefinition[$i]->getVar() !== $parameterName) {
                throw new \Exception(sprintf(
                    "Invalid phpdoc on param '%s' with name '%s' for method '%s:%s'",
                    $parameterName,
                    $parametersDefinition[$i]->getVar(),
                    get_class($this),
                    $method
                ));
            }

            $value = $this->getFinalValue(
                $parametersDefinition[$i]->getType(),
                $parametersDefinition[$i]->getVar(),
                $value,
                $parameter->isOptional()
            );

            if ($parametersDefinition[$i]->getValidation()) {
                $value = $parametersDefinition[$i]->validateCondition($parameterName, $value);
            }

            if ($parameter->isDefaultValueAvailable() && $value === null) {
                $value = $parameter->getDefaultValue();
            }

            $return[] = $value;
        }

        return $return;
    }
770708
public function mergeParams($method, Array $params = [])
    {
        $result = parent::mergeParams($method, $params);

        foreach ($this->map as $oldKey => $newKey)
        {
            if (array_key_exists($oldKey, $result[$method])) {
                $result[$method][$newKey] = $result[$method][$oldKey];
                $result[$method][$oldKey] = null;
                unset($result[$method][$oldKey]);
            }
        }

        return $result;
    }
446296
public final function getMethodArguments(string $method = null): ?array
    {
        return $method ? $this->methodArguments[$method] ?? null : $this->methodArguments;
    }
870927
public function parameterize($method)
    {
        $parameterArray = parent::parameterize($method);

        if ('create' == $method) {
            if ($this->getFirstName()) {
                $parameterArray['first_name'] = $this->getFirstName();
            }

            if ($this->getLastName()) {
                $parameterArray['last_name'] = $this->getLastName();
            }

            if ($this->getCountry()) {
                $parametersArray['country'] = $this->getCountry();
            }

            if ($this->getClientEmail()) {
                $parametersArray['client_email'] = $this->getClientEmail();
            }

            if ($this->getBillingAddress()) {
                $parametersArray['billing_address'] = $this->getBillingAddress();
            }

            if ($this->getClientPhoneNumber()) {
                $parametersArray['client_phone_number'] = $this->getClientPhoneNumber();
            }
        }

        return $parameterArray;
    }