Function createMethodsCache
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
private function createMethodsCache()
{
$routing = $this->route->getRouting();
$config = array();
Method pregUrl
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
public function pregUrl($matches, $routeKey, $routing)
{
$requestUri = $this->route->getUri();
if (substr($requestUri, -1) == "/") {
$requestUri = substr($requestUri, 0, -1);
Function getRoutingConfig
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
private function getRoutingConfig()
{
$file = 'route/routing.php';
if ($this->container->getEnvironment() == "prod") {
Function match
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
public function match()
{
$requestUri = $this->route->getUri();
$routing = $this->getRouting();
Avoid using undefined variables such as '$parameterValue' which will lead to PHP notices.
return $parameterValue;
Avoid using undefined variables such as '$filterParameters' which will lead to PHP notices.
$this->route->setParametersName($filterParameters);
Avoid using undefined variables such as '$filterParameters' which will lead to PHP notices.
$filterParameters[] = $match;
Avoid using undefined variables such as '$filterParameters' which will lead to PHP notices.
$config['parameters'] = $this->mergeParameters($filterParameters, $values);
Avoid using undefined variables such as '$parameterValue' which will lead to PHP notices.
$parameterValue[$parameter] = $values[$key+1][0];
Avoid using undefined variables such as '$parameters' which will lead to PHP notices.
$parameters[] = $match;
The class Router has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
Class Router implements RouterContract
{
/**
* 支持的http方法
*
The method getRoutingConfig uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$routing = include_once "src/{$source}/routing.php";
}
The method controller uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$this->container->setResponse(new Response($tplData));
}
Avoid unused local variables such as '$parameters'.
$parameters[] = $match;
Avoid unused local variables such as '$route'.
foreach ($routing as $routeKey => $route) {
PHP keywords must be lowercase; expected "class" but found "Class"
Class Router implements RouterContract
Blank line found at end of control structure
Expected 0 spaces before closing bracket; 1 found
if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;
Line exceeds 120 characters; contains 159 characters
return $this->container->doAction($className, $action, isset($config['parameters']) ? $config['parameters'] : array(), $this->container->getRequest());
Inline control structures are not allowed
if(isset($route['methods']) && !in_array(strtoupper($route['methods']), $this->methods)) continue;
Line exceeds 120 characters; contains 121 characters
if ($tplData instanceof Response || $tplData instanceof \RedirectResponse || $tplData instanceof \JsonResponse) {
Inline control structures are not allowed
if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;
Line exceeds 120 characters; contains 124 characters
if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;
Line indented incorrectly; expected 12 spaces, found 16
}
Whitespace found at end of line
\EventDispatcher::dispatch(KernalEvent::NOTFOUND, new HttpEvent($this->container->getRequest()));
Whitespace found at end of line
{
Expected 1 space after IF keyword; 0 found
if(\FileCache::isExist($file)) {
Whitespace found at end of line
{
Expected 1 space after IF keyword; 0 found
if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;
Line indented incorrectly; expected 12 spaces, found 16
if(!isset($route['methods'])) {
Whitespace found at end of line
{
Expected 1 space after IF keyword; 0 found
if(\FileCache::isExist($file)) {
Whitespace found at end of line
{
Expected 1 space after IF keyword; 0 found
if(!isset($route['methods'])) {
Whitespace found at end of line
{
Expected 1 space after IF keyword; 0 found
if(isset($route['methods']) && !in_array(strtoupper($route['methods']), $this->methods)) continue;
Whitespace found at end of line
}
There are no issues that match your filters.