Skip to content
Permalink
Browse files

Start adding some actual parsing

  • Loading branch information...
jacobemerick committed Oct 4, 2016
1 parent e34abde commit f73955eece3c8f100303f19fb503f85625483689
Showing with 36 additions and 2 deletions.
  1. +36 −2 src/ParameterParser.php
@@ -37,11 +37,45 @@ public function __invoke(RequestInterface $request, array $parameter)
$value = $parameter['default'];
}
// todo break apart arrays
// todo cast into respective data types
return $value;
}
protected function getQueryValue(RequestInterface $request, $name) {}
protected function getHeaderValue(RequestInterface $request, $name) {}
/**
* @param RequestInterface $request
* @param string $name
* @returns mixed
*/
protected function getQueryValue(RequestInterface $request, $name)
{
parse_str($request->getUri()->getQuery(), $query);
if (!array_key_exists($name, $query)) {
return;
}
return $query[$name];
}
/**
* @param RequestInterface $request
* @param string $name
* @returns mixed
*/
protected function getHeaderValue(RequestInterface $request, $name)
{
$headers = $request->getHeaders();
if (!array_key_exists($name, $headers)) {
return;
}
if (count($headers[$name]) === 1) {
return current($headers[$name]);
}
return $headers[$name]; // todo this will break array parser
}
protected function getPathValue(RequestInterface $request, $name) {}
protected function getFormDataValue(RequestInterface $request, $name) {}
protected function getBodyValue(RequestInterface $request, $name) {}

0 comments on commit f73955e

Please sign in to comment.
You can’t perform that action at this time.