API updates.

This commit is contained in:
James Cole
2019-06-09 08:26:23 +02:00
parent 85f9c256a1
commit 3c2dfc52bc
35 changed files with 722 additions and 573 deletions

View File

@@ -56,11 +56,35 @@ class Controller extends BaseController
$this->parameters = $this->getParameters();
}
/**
* Method to help build URI's.
*
* @return string
*
*/
protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
$return .= http_build_query($params);
return $return;
}
/**
* Method to grab all parameters from the URI.
*
* @return ParameterBag
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
private function getParameters(): ParameterBag
{
@@ -99,30 +123,4 @@ class Controller extends BaseController
return $bag;
}
/**
* Method to help build URI's.
*
* @return string
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
$return .= http_build_query($params);
return $return;
}
}