Submit
Path:
~
/
/
opt
/
psa
/
admin
/
plib
/
modules
/
platform360
/
vendor
/
nikic
/
fast-route
/
src
/
Dispatcher
/
File Content:
RegexBasedAbstract.php
<?php namespace Platform360\FastRoute\Dispatcher; use Platform360\FastRoute\Dispatcher; abstract class RegexBasedAbstract implements Dispatcher { /** @var mixed[][] */ protected $staticRouteMap = []; /** @var mixed[] */ protected $variableRouteData = []; /** * @return mixed[] */ protected abstract function dispatchVariableRoute($routeData, $uri); public function dispatch($httpMethod, $uri) { if (isset($this->staticRouteMap[$httpMethod][$uri])) { $handler = $this->staticRouteMap[$httpMethod][$uri]; return [self::FOUND, $handler, []]; } $varRouteData = $this->variableRouteData; if (isset($varRouteData[$httpMethod])) { $result = $this->dispatchVariableRoute($varRouteData[$httpMethod], $uri); if ($result[0] === self::FOUND) { return $result; } } // For HEAD requests, attempt fallback to GET if ($httpMethod === 'HEAD') { if (isset($this->staticRouteMap['GET'][$uri])) { $handler = $this->staticRouteMap['GET'][$uri]; return [self::FOUND, $handler, []]; } if (isset($varRouteData['GET'])) { $result = $this->dispatchVariableRoute($varRouteData['GET'], $uri); if ($result[0] === self::FOUND) { return $result; } } } // If nothing else matches, try fallback routes if (isset($this->staticRouteMap['*'][$uri])) { $handler = $this->staticRouteMap['*'][$uri]; return [self::FOUND, $handler, []]; } if (isset($varRouteData['*'])) { $result = $this->dispatchVariableRoute($varRouteData['*'], $uri); if ($result[0] === self::FOUND) { return $result; } } // Find allowed methods for this URI by matching against all other HTTP methods as well $allowedMethods = []; foreach ($this->staticRouteMap as $method => $uriMap) { if ($method !== $httpMethod && isset($uriMap[$uri])) { $allowedMethods[] = $method; } } foreach ($varRouteData as $method => $routeData) { if ($method === $httpMethod) { continue; } $result = $this->dispatchVariableRoute($routeData, $uri); if ($result[0] === self::FOUND) { $allowedMethods[] = $method; } } // If there are no allowed methods the route simply does not exist if ($allowedMethods) { return [self::METHOD_NOT_ALLOWED, $allowedMethods]; } return [self::NOT_FOUND]; } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
CharCountBased.php
787 bytes
0644
GroupCountBased.php
772 bytes
0644
GroupPosBased.php
846 bytes
0644
MarkBased.php
766 bytes
0644
RegexBasedAbstract.php
2775 bytes
0644
N4ST4R_ID | Naxtarrr