fucongcong/framework

View on GitHub
core/Group/Routing/Router.php

Summary

Maintainability
A
3 hrs
Test Coverage

Showing 37 of 37 total issues

Function createMethodsCache has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

private function createMethodsCache()
{
$routing = $this->route->getRouting();
 
$config = array();
Severity: Minor
Found in core/Group/Routing/Router.php - About 1 hr to fix

Method pregUrl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function pregUrl($matches, $routeKey, $routing)
{
$requestUri = $this->route->getUri();
if (substr($requestUri, -1) == "/") {
$requestUri = substr($requestUri, 0, -1);
Severity: Minor
Found in core/Group/Routing/Router.php - About 1 hr to fix

    Function getRoutingConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    private function getRoutingConfig()
    {
    $file = 'route/routing.php';
     
    if ($this->container->getEnvironment() == "prod") {
    Severity: Minor
    Found in core/Group/Routing/Router.php - About 55 mins to fix

    Function match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    public function match()
    {
    $requestUri = $this->route->getUri();
     
    $routing = $this->getRouting();
    Severity: Minor
    Found in core/Group/Routing/Router.php - About 25 mins to fix

    Avoid using undefined variables such as '$parameterValue' which will lead to PHP notices.
    Open

    return $parameterValue;
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    Avoid using undefined variables such as '$filterParameters' which will lead to PHP notices.
    Open

    $this->route->setParametersName($filterParameters);
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    Avoid using undefined variables such as '$filterParameters' which will lead to PHP notices.
    Open

    $filterParameters[] = $match;
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    Avoid using undefined variables such as '$filterParameters' which will lead to PHP notices.
    Open

    $config['parameters'] = $this->mergeParameters($filterParameters, $values);
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    Avoid using undefined variables such as '$parameterValue' which will lead to PHP notices.
    Open

    $parameterValue[$parameter] = $values[$key+1][0];
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    Avoid using undefined variables such as '$parameters' which will lead to PHP notices.
    Open

    $parameters[] = $match;
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    The class Router has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
    Open

    Class Router implements RouterContract
    {
    /**
    * 支持的http方法
    *
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    The method getRoutingConfig uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

    } else {
    $routing = include_once "src/{$source}/routing.php";
    }
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    The method controller uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

    } else {
    $this->container->setResponse(new Response($tplData));
    }
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    Avoid unused local variables such as '$parameters'.
    Open

    $parameters[] = $match;
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    Avoid unused local variables such as '$route'.
    Open

    foreach ($routing as $routeKey => $route) {
    Severity: Minor
    Found in core/Group/Routing/Router.php by phpmd

    PHP keywords must be lowercase; expected "class" but found "Class"
    Open

    Class Router implements RouterContract

    Blank line found at end of control structure
    Open

     
     

    Expected 0 spaces before closing bracket; 1 found
    Open

    if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;

    Line exceeds 120 characters; contains 159 characters
    Open

    return $this->container->doAction($className, $action, isset($config['parameters']) ? $config['parameters'] : array(), $this->container->getRequest());

    Inline control structures are not allowed
    Open

    if(isset($route['methods']) && !in_array(strtoupper($route['methods']), $this->methods)) continue;

    Line exceeds 120 characters; contains 121 characters
    Open

    if ($tplData instanceof Response || $tplData instanceof \RedirectResponse || $tplData instanceof \JsonResponse) {

    Inline control structures are not allowed
    Open

    if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;

    Line exceeds 120 characters; contains 124 characters
    Open

    if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;

    Line indented incorrectly; expected 12 spaces, found 16
    Open

    }

    Whitespace found at end of line
    Open

    \EventDispatcher::dispatch(KernalEvent::NOTFOUND, new HttpEvent($this->container->getRequest()));

    Whitespace found at end of line
    Open

    {

    Expected 1 space after IF keyword; 0 found
    Open

    if(\FileCache::isExist($file)) {

    Whitespace found at end of line
    Open

    {

    Expected 1 space after IF keyword; 0 found
    Open

    if(isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods']) ) continue;

    Line indented incorrectly; expected 12 spaces, found 16
    Open

    if(!isset($route['methods'])) {

    Whitespace found at end of line
    Open

    {

    Expected 1 space after IF keyword; 0 found
    Open

    if(\FileCache::isExist($file)) {

    Whitespace found at end of line
    Open

    {

    Expected 1 space after IF keyword; 0 found
    Open

    if(!isset($route['methods'])) {

    Whitespace found at end of line
    Open

    {

    Expected 1 space after IF keyword; 0 found
    Open

    if(isset($route['methods']) && !in_array(strtoupper($route['methods']), $this->methods)) continue;

    Whitespace found at end of line
    Open

    }

    There are no issues that match your filters.

    Category
    Status