NatLibFi/Skosmos

View on GitHub
src/model/Request.php

Summary

Maintainability
A
3 hrs
Test Coverage
C
77%

Request has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class Request
{
    private $lang;
    private $clang;
    private $page;
Severity: Minor
Found in src/model/Request.php - About 3 hrs to fix

    The class Request has an overall complexity of 57 which is very high. The configured complexity threshold is 50.
    Open

    class Request
    {
        private $lang;
        private $clang;
        private $page;
    Severity: Minor
    Found in src/model/Request.php by phpmd

    The method __construct() has an NPath complexity of 256. The configured NPath complexity threshold is 200.
    Open

        public function __construct($model)
        {
            $this->model = $model;
    
            // Store GET parameters in a local array, so we can mock them in tests.
    Severity: Minor
    Found in src/model/Request.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    Missing class import via use statement (line '307', column '20').
    Open

            return new PluginRegister($this->model->getConfig()->getGlobalPlugins());
    Severity: Minor
    Found in src/model/Request.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

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

            } else {
                $this->vocab = $this->model->getVocabulary($vocabid);
            }
    Severity: Minor
    Found in src/model/Request.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    The variable $script_name is not named in camelCase.
    Open

        public function getLangUrl($newlang = null)
        {
            $script_name = str_replace('/src/index.php', '', $this->getServerConstant('SCRIPT_NAME'));
            $langurl = substr(str_replace($script_name, '', strval($this->getServerConstant('REQUEST_URI'))), 1);
            if ($newlang !== null) {
    Severity: Minor
    Found in src/model/Request.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 $script_name is not named in camelCase.
    Open

        public function getLangUrl($newlang = null)
        {
            $script_name = str_replace('/src/index.php', '', $this->getServerConstant('SCRIPT_NAME'));
            $langurl = substr(str_replace($script_name, '', strval($this->getServerConstant('REQUEST_URI'))), 1);
            if ($newlang !== null) {
    Severity: Minor
    Found in src/model/Request.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

    There are no issues that match your filters.

    Category
    Status