speedworks/speedy

View on GitHub
Core/Bridge.php

Summary

Maintainability
A
2 hrs
Test Coverage

__construct accesses the super-global variable $_ENV.
Open

    public function __construct()
    {
        require (__DIR__ . "/Classes/Helpers.php");
        require (__DIR__ . "/../App/Routes.php");
        header('Access-Control-Allow-Origin: '.$_ENV['cors']);
Severity: Minor
Found in Core/Bridge.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method Pass has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function Pass($requestUri, $requestMethod, $requestData, $rawData)
    {
        if(!array_key_exists($requestMethod,Route::$URLS))
        {
            System::GiveError(405,"Method not allowed");
Severity: Minor
Found in Core/Bridge.php - About 1 hr to fix

    Function Pass has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function Pass($requestUri, $requestMethod, $requestData, $rawData)
        {
            if(!array_key_exists($requestMethod,Route::$URLS))
            {
                System::GiveError(405,"Method not allowed");
    Severity: Minor
    Found in Core/Bridge.php - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    The method Pass() contains an exit expression.
    Open

                exit(0);
    Severity: Minor
    Found in Core/Bridge.php by phpmd

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

    Source https://phpmd.org/rules/design.html#exitexpression

    The variable $URLS is not named in camelCase.
    Open

        public static function Pass($requestUri, $requestMethod, $requestData, $rawData)
        {
            if(!array_key_exists($requestMethod,Route::$URLS))
            {
                System::GiveError(405,"Method not allowed");
    Severity: Minor
    Found in Core/Bridge.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $URLS is not named in camelCase.
    Open

        public static function Pass($requestUri, $requestMethod, $requestData, $rawData)
        {
            if(!array_key_exists($requestMethod,Route::$URLS))
            {
                System::GiveError(405,"Method not allowed");
    Severity: Minor
    Found in Core/Bridge.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The method Pass is not named in camelCase.
    Open

        public static function Pass($requestUri, $requestMethod, $requestData, $rawData)
        {
            if(!array_key_exists($requestMethod,Route::$URLS))
            {
                System::GiveError(405,"Method not allowed");
    Severity: Minor
    Found in Core/Bridge.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status