handles single param

@param   \stubbles\input\Request  $request
@param   string                   $paramName
@param   bool                     $required
@return  \stubbles\input\ValueReader
345121
private function readValue(
            Request $request,
            string $paramName,
            bool $required,
            Date $default = null
    ): CommonValueReader {
        $valueFilter = $request->readParam($paramName);
        if ($required) {
            return $valueFilter->required();
        } elseif (null !== $default) {
            return $valueFilter->defaultingTo($default);
        }

        return $valueFilter;
    }
777501
public function loadResponseHeader($paramName)
    {
        $headers = $this->getResponseHeader();

        if (array_key_exists($paramName, $headers)) {
            $this->contextDataExists = true;
            $this->contextDataValue  = $headers[$paramName];
        }

        return $this->checkDataIsEmpty();
    }
484231
static function checkRequiredParameters(array $given, array $required)
    {
        foreach ($required as $key) {
            if (!array_key_exists($key, $given)) {
                throw new MissingRequiredParameterException(
                        "Missing required parameter '$key'"
                );
            }
        }
    }
939323
public function requestPdo($request, $param = null)
    {
        $this->result = $this->tableGateway->requestPdo($request, $param);

        return $this->result;
    }
76185
public function loadRequestPath($paramName)
    {
        // parse from the end to the top
        $path = array_reverse(explode('/', $this->contextRequestPath));

        /**
         * -1 => current params
         * -2 => method
         * -3 => route
         */
        $datapath     = $this->__get('DataPath');
        $partDataPath = null;

        while (true) {
            if (!is_array($datapath) || empty($datapath)) {
                $partDataPath = null;
                break;
            }

            $partDataPath = array_pop($datapath);

            if (substr($partDataPath, 0, 1) == '/') {
                break;
            }
        }

        // parse from the end to the top
        $route = array_reverse(explode('/', $partDataPath));

        foreach ($route as $key => $partRoute) {

            if ($partRoute != '{' . $paramName . '}') {
                continue;
            }

            if (!array_key_exists($key, $path)) {
                $this->contextDataExists = false;
                $this->contextDataValue  = null;
                break;
            }

            $this->contextDataExists = true;
            $this->contextDataValue  = urldecode($path[$key]);
        }

        return $this->checkDataIsEmpty();
    }
1185287
public function getParameter($paramName) {
		if(isset($this->params[$paramName])) {
					return $this->params[$paramName];
		}
		return null;
	}
1213968
public function executeRequest(Request $request)
    {
        $curl = curl_init();

        if ($request->getPostBody()) {
            curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getPostBody());
        }

        $requestHeaders = $request->getRequestHeaders();
        if ($requestHeaders && is_array($requestHeaders)) {
            $curlHeaders = array();
            foreach ($requestHeaders as $k => $v) {
                $curlHeaders[] = "$k: $v";
            }
            curl_setopt($curl, CURLOPT_HTTPHEADER, $curlHeaders);
        }
        curl_setopt($curl, CURLOPT_URL, $request->getUrl());

        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestMethod());
        curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());

        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
        // 1 is CURL_SSLVERSION_TLSv1, which is not always defined in PHP.
        curl_setopt($curl, CURLOPT_SSLVERSION, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);

        if ($request->canGzip()) {
            curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
        }

        $options = $this->client->getClassConfig('Goracash\IO\Curl', 'options');
        if (is_array($options)) {
            $this->setOptions($options);
        }

        foreach ($this->options as $key => $var) {
            curl_setopt($curl, $key, $var);
        }

        $this->client->getLogger()->debug(
            'cURL request',
            array(
                'url' => $request->getUrl(),
                'method' => $request->getRequestMethod(),
                'headers' => $requestHeaders,
                'body' => $request->getPostBody()
            )
        );

        $result = curl_exec($curl);
        if ($result === false) {
            $error = curl_error($curl);
            $code = curl_errno($curl);
            $this->client->getLogger()->error('cURL ' . $error);
            throw new Exception($error, $code);
        }

        $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        list($responseHeaders, $responseBody) = $this->parseHttpResponse($result, $headerSize);

        $response = new Response();
        $response->code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $response->url = $request->getUrl();
        $response->method = $request->getRequestMethod();
        $response->headers = $responseHeaders;
        $response->body = $responseBody;
        $response->status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $response->setContentType(curl_getinfo($curl, CURLINFO_CONTENT_TYPE));

        $this->client->getLogger()->debug(
            'cURL response',
            array(
                'code' => $response->code,
                'headers' => $response->headers,
                'body' => $response->body,
            )
        );
        return $response;
    }
781881
public function request($requestParams, $url, $method, $requiredParams, $options)
    {
        $client = $this->getHttpClient();
        $url = $this->buildEndpoint($url);

        return $client->httpRequest($requestParams, $url, $method, $requiredParams, $options);
    }
1210457
private function getParameter($paramName)
	{
		if (array_key_exists($paramName, $_REQUEST))
		{
			return str_replace(FileUtil::Slash().FileUtil::Slash(), FileUtil::Slash(), $_REQUEST[$paramName]);
		}
		else
		{
			return "";
		}
	}
1134705
public function handle(Request $request)
	{
		$response = $this->next($request);

		// If CLI then we have to gather all query, post and header values
		// into params for Oauth_Provider's constructor.
		$params = array();

		if ($this->app->runningInConsole())
		{
			$queryvars = $this->app['request']->get('queryvars');
			$postvars  = $this->app['request']->get('postdata');

			if (!empty($queryvars))
			{
				foreach ($queryvars as $key => $value)
				{
					if (isset($queryvars[$key]))
					{
						$params[$key] = $queryvars[$key];
					}
					else if (isset($postvars[$key]))
					{
						$params[$key] = $postvars[$key];
					}
				}
			}

			if (!empty($postvars))
			{
				foreach ($postvars as $key => $value)
				{
					if (isset($queryvars[$key]))
					{
						$params[$key] = $queryvars[$key];
					}
					else if (isset($postvars[$key]))
					{
						$params[$key] = $postvars[$key];
					}
				}
			}

			if (empty($params))
			{
				return false;
			}
		}

		$this->app['authn'] = $this->app['auth']->authenticate($params);

		$this->app['request']->setVar('validApiKey', !empty($this->app['authn']['consumer_key']));

		return $response;
	}
166327
public static String getParameter(final Request request, final String parameterName)
	{
		String parameterValue = request.getRequestParameters().getParameterValue(parameterName)
			.toString();
		if ((parameterValue == null) || parameterValue.isEmpty())
		{
			parameterValue = request.getPostParameters().getParameterValue(parameterName)
				.toString();
		}
		if ((parameterValue == null) || parameterValue.isEmpty())
		{
			parameterValue = request.getQueryParameters().getParameterValue(parameterName)
				.toString();
		}
		if ((parameterValue == null) || parameterValue.isEmpty())
		{
			parameterValue = request.getRequestParameters().getParameterValue(parameterName)
				.toString();
		}
		return parameterValue;
	}
1220698
private function applyConverter(Request $request, ParamConverter $configuration)
    {
        $value = $request->attributes->get($configuration->getName());
        $className = $configuration->getClass();

        // If the value is already an instance of the class we are trying to convert it into
        // we should continue as no conversion is required
        if (\is_object($value) && $value instanceof $className) {
            return;
        }

        if ($converterName = $configuration->getConverter()) {
            if (!isset($this->namedConverters[$converterName])) {
                throw new \RuntimeException(sprintf(
                    "No converter named '%s' found for conversion of parameter '%s'.",
                    $converterName,
                    $configuration->getName()
                ));
            }

            $converter = $this->namedConverters[$converterName];

            if (!$converter->supports($configuration)) {
                throw new \RuntimeException(sprintf(
                    "Converter '%s' does not support conversion of parameter '%s'.",
                    $converterName,
                    $configuration->getName()
                ));
            }

            $converter->apply($request, $configuration);

            return;
        }

        foreach ($this->all() as $converter) {
            if ($converter->supports($configuration)) {
                if ($converter->apply($request, $configuration)) {
                    return;
                }
            }
        }
    }
1135524
public function build($required, $params)
    {
        $this->errors = [];
        $this->methodParams = [];
        $availableParams = $params;
        $this->checkParams($params);
        foreach ($required as $position => $infos) {
            /**
             * If a parameter is named, we just set it
             * The setParams method will check if the object is of correct type
             */
            if (!empty($availableParams[$infos['name']])) {
                $this->setParams($position, $infos, $availableParams[$infos['name']]);
                unset($availableParams[$infos['name']]);
            } else {
                $hasParams = false;
                /**
                 * If we have a class, we search a candidate for the injection
                 * If the parameter is scalar, it __MUST__ be named, otherwise we can't match it
                 */
                if (!empty($infos['class'])) {
                    // Searching by class if we found it
                    $searchedClass = $infos['class'];
                    foreach ($availableParams as $key => $type) {
                        if ($type instanceof $searchedClass) {
                            if (is_numeric($key) || $key === $infos['name']) {
                                $this->setParams($position, $infos, $type);
                                $hasParams = true;
                            }
                            unset($availableParams[$key]);
                            break;
                        }
                    }
                }
                if (!$hasParams) {
                    $this->errors[] = sprintf("Can't find matching dependancy for parameter #%s $%s of type %s", $position, $infos['name'], !empty($infos['class']) ? $infos['class'] : 'scalar type');
                }
            }
        }

    }
1056760
public function parse(Request $request)
    {
        if ($request->has($this->name)) {
            $this->applied = true;
            $value         = $request->input($this->name);
            $operation     = substr($value, 0, 1);
            if ($operation === '!') {
                $this->operation = '!=';
                $this->value     = substr($value, 1);
            } else {
                $this->value = $value;
            }
        }
    }
996603
public function param( $param_name, $callback )
	{
		if( is_callable($callback) )
		{
			$this->_params[$param_name] = $callback( new request() );
		}
		else
		{
			$this->_params[$param_name] = $callback;
		}
	}
42578
protected function setParams($position, $required, $param)
    {
        if (!empty($required['class']) && !is_a($param, $required['class'])) {
            $this->errors[] = sprintf("You can't put an instance of %s in the parameter #%s $%s of type %s",
                get_class($param), $position, $required['name'], $required['class']);
            return false;
        }
        $this->methodParams[$position] = $param;
    }
97474
public function apply(Request $request, ParamConverter $configuration)
    {
        $slug = $request->get('slug', null);
        $username = $request->get('username', null);
        $id = $request->get('id', null);

        if ($slug)
        {
            $searchArray = array('slug' => $slug);
        }
        elseif($username)
        {
            $searchArray = array('username' => $username);
        }
        elseif($id)
        {
            $searchArray = array('id' => $id);
        }
        else
        {
            throw new \InvalidArgumentException('Route attribute is missing');
        }

        $class = $this->targetEntitiesArray[$configuration->getClass()];

        $repository = $this->doctrine->getRepository($class);

        $object = $repository->findOneBy( $searchArray );

        if(!$object)
            throw new NotFoundHttpException("Sorry, requested resource can't be found.");

        $request->attributes->set($configuration->getName(), $object);

    }