Submit
Path:
~
/
/
proc
/
self
/
root
/
opt
/
psa
/
phpMyAdmin
/
vendor
/
nikic
/
fast-route
/
src
/
Dispatcher
/
File Content:
RegexBasedAbstract.php
<?php namespace FastRoute\Dispatcher; use FastRoute\Dispatcher; abstract class RegexBasedAbstract implements Dispatcher { /** @var mixed[][] */ protected $staticRouteMap = []; /** @var mixed[] */ protected $variableRouteData = []; /** * @return mixed[] */ abstract protected 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
777 bytes
0644
GroupCountBased.php
762 bytes
0644
GroupPosBased.php
823 bytes
0644
MarkBased.php
757 bytes
0644
RegexBasedAbstract.php
2764 bytes
0644
N4ST4R_ID | Naxtarrr