// the first path element is the overall scope of the request
$scope = $url[0];
// any URL components which are database IDs (integers greater than zero) should be replaced with "1", for easier comparison (we don't care about the specific ID)
// any URL components which are database IDs (integers greater than zero) should be replaced with "1", for easier comparison (we don't care about the specific ID)
for ($a = 0; $a <sizeof($url);$a++){
for ($a = 0; $a <sizeof($url);$a++){
if (ValueInfo::id($url[$a])) {
if (ValueInfo::id($url[$a])) {
$url[$a] = "1";
$url[$a] = "1";
}
}
}
}
return implode("/", $url);
}
protected function chooseCall(array $url, string $method): string {
// normalize the URL path
$url = $this->normalizePath($url);
// normalize the HTTP method to uppercase
// normalize the HTTP method to uppercase
$method = strtoupper($method);
$method = strtoupper($method);
// if the scope is not supported, return 501
if (!array_key_exists($scope, $choices)) {
throw new Exception501();
}
// we now evaluate the supplied URL against every supported path for the selected scope
// we now evaluate the supplied URL against every supported path for the selected scope
// the URL is evaluated as an array so as to avoid decoded escapes turning invalid URLs into valid ones
// the URL is evaluated as an array so as to avoid decoded escapes turning invalid URLs into valid ones
foreach ($choices[$scope] as $path => $funcs) {
foreach ($this->paths as $path => $funcs) {
// add the scope to the path to match against and split it