NatLibFi/Skosmos

View on GitHub
src/model/Model.php

Summary

Maintainability
F
3 days
Test Coverage
B
82%

File Model.php has 419 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Importing the dependencies.
 */
Severity: Minor
Found in src/model/Model.php - About 6 hrs to fix

    Function disambiguateVocabulary has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null)
        {
            // if there is only one candidate vocabulary, return it
            if (sizeof($vocabs) == 1) {
                return $vocabs[0];
    Severity: Minor
    Found in src/model/Model.php - About 4 hrs 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

    Model has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Model
    {
        /** cache for Vocabulary objects */
        private $allVocabularies = null;
        /** cache for Vocabulary objects */
    Severity: Minor
    Found in src/model/Model.php - About 3 hrs to fix

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

      class Model
      {
          /** cache for Vocabulary objects */
          private $allVocabularies = null;
          /** cache for Vocabulary objects */
      Severity: Minor
      Found in src/model/Model.php by phpmd

      Function searchConcepts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function searchConcepts($params)
          {
              // don't even try to search for empty prefix if no other search criteria (group or parent concept) has been set
              if (($params->getSearchTerm() === "" || !preg_match('/[^*]/', $params->getSearchTerm())) && !$params->getGroupLimit() && !$params->getParentLimit()) {
                  return array();
      Severity: Minor
      Found in src/model/Model.php - About 2 hrs 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

      Method searchConcepts has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function searchConcepts($params)
          {
              // don't even try to search for empty prefix if no other search criteria (group or parent concept) has been set
              if (($params->getSearchTerm() === "" || !preg_match('/[^*]/', $params->getSearchTerm())) && !$params->getGroupLimit() && !$params->getParentLimit()) {
                  return array();
      Severity: Minor
      Found in src/model/Model.php - About 1 hr to fix

        Function searchConceptsAndInfo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function searchConceptsAndInfo($params)
            {
                $params->setUnique(true);
                $allhits = $this->searchConcepts($params);
                $count = sizeof($allhits);
        Severity: Minor
        Found in src/model/Model.php - About 1 hr 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

        Function getTypes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getTypes($vocid = null, $lang = null)
            {
                $sparql = (isset($vocid)) ? $this->getVocabulary($vocid)->getSparql() : $this->getDefaultSparql();
                $result = $sparql->queryTypes($lang);
                foreach ($result as $uri => $values) {
        Severity: Minor
        Found in src/model/Model.php - About 1 hr 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

        Method searchConceptsAndInfo has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function searchConceptsAndInfo($params)
            {
                $params->setUnique(true);
                $allhits = $this->searchConcepts($params);
                $count = sizeof($allhits);
        Severity: Minor
        Found in src/model/Model.php - About 1 hr to fix

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

              private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null)
              {
                  // if there is only one candidate vocabulary, return it
                  if (sizeof($vocabs) == 1) {
                      return $vocabs[0];
          Severity: Minor
          Found in src/model/Model.php - About 1 hr to fix

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

                public function guessVocabularyFromURI($uri, $preferredVocabId = null)
                {
                    if ($this->vocabsByUriSpace === null) { // initialize cache
                        $this->vocabsByUriSpace = array();
                        foreach ($this->getVocabularies() as $voc) {
            Severity: Minor
            Found in src/model/Model.php - About 1 hr 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

            Function getVocabularies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getVocabularies()
                {
                    if ($this->allVocabularies === null) { // initialize cache
                        $vocs = $this->globalConfig->getGraph()->allOfType('skosmos:Vocabulary');
                        $this->allVocabularies = $this->createDataObjects("Vocabulary", $vocs);
            Severity: Minor
            Found in src/model/Model.php - About 1 hr 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

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

                public function getVocabularyList($categories = true, $shortname = false)
                {
                    $cats = $this->getVocabularyCategories();
                    $ret = array();
                    foreach ($cats as $cat) {
            Severity: Minor
            Found in src/model/Model.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

            Function getRDF has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getRDF($vocid, $uri, $format)
                {
            
                    if ($format == 'text/turtle') {
                        $retform = 'turtle';
            Severity: Minor
            Found in src/model/Model.php - About 35 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

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

                public function getVocabularyByGraph($graph, $endpoint = null)
                {
                    if ($endpoint === null) {
                        $endpoint = $this->getConfig()->getDefaultEndpoint();
                    }
            Severity: Minor
            Found in src/model/Model.php - About 25 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 searchConceptsAndInfo() has an NPath complexity of 440. The configured NPath complexity threshold is 200.
            Open

                public function searchConceptsAndInfo($params)
                {
                    $params->setUnique(true);
                    $allhits = $this->searchConcepts($params);
                    $count = sizeof($allhits);
            Severity: Minor
            Found in src/model/Model.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

            The method searchConcepts() has an NPath complexity of 1000. The configured NPath complexity threshold is 200.
            Open

                public function searchConcepts($params)
                {
                    // don't even try to search for empty prefix if no other search criteria (group or parent concept) has been set
                    if (($params->getSearchTerm() === "" || !preg_match('/[^*]/', $params->getSearchTerm())) && !$params->getGroupLimit() && !$params->getParentLimit()) {
                        return array();
            Severity: Minor
            Found in src/model/Model.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

            The method disambiguateVocabulary() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
            Open

                private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null)
                {
                    // if there is only one candidate vocabulary, return it
                    if (sizeof($vocabs) == 1) {
                        return $vocabs[0];
            Severity: Minor
            Found in src/model/Model.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

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

            The method searchConceptsAndInfo() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
            Open

                public function searchConceptsAndInfo($params)
                {
                    $params->setUnique(true);
                    $allhits = $this->searchConcepts($params);
                    $count = sizeof($allhits);
            Severity: Minor
            Found in src/model/Model.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

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

            The method searchConcepts() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
            Open

                public function searchConcepts($params)
                {
                    // don't even try to search for empty prefix if no other search criteria (group or parent concept) has been set
                    if (($params->getSearchTerm() === "" || !preg_match('/[^*]/', $params->getSearchTerm())) && !$params->getGroupLimit() && !$params->getParentLimit()) {
                        return array();
            Severity: Minor
            Found in src/model/Model.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

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

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

            class Model
            {
                /** cache for Vocabulary objects */
                private $allVocabularies = null;
                /** cache for Vocabulary objects */
            Severity: Minor
            Found in src/model/Model.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

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

            Missing class import via use statement (line '62', column '29').
            Open

                    $this->logger = new \Monolog\Logger('general');
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '63', column '26').
            Open

                    $formatter = new \Monolog\Formatter\LineFormatter("[%datetime%] %level_name% %message%\n");
            Severity: Minor
            Found in src/model/Model.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

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

                    $this->globalConfig = new GlobalConfig($this, $config_filename);
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '34', column '31').
            Open

                    $this->resolver = new Resolver($this);
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '66', column '35').
            Open

                        $browserHandler = new \Monolog\Handler\BrowserConsoleHandler(\Monolog\Logger::INFO);
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '71', column '34').
            Open

                        $streamHandler = new \Monolog\Handler\StreamHandler($this->getConfig()->getLoggingFilename(), \Monolog\Logger::INFO);
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '77', column '32').
            Open

                        $nullHandler = new \Monolog\Handler\NullHandler();
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '236', column '31').
            Open

                        $serialiser = new EasyRdf\Serialiser\Turtle();
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '242', column '31').
            Open

                        $serialiser = new EasyRdf\Serialiser\RdfXml();
            Severity: Minor
            Found in src/model/Model.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 getVocabularyList has a boolean flag argument $shortname, which is a certain sign of a Single Responsibility Principle violation.
            Open

                public function getVocabularyList($categories = true, $shortname = false)
            Severity: Minor
            Found in src/model/Model.php by phpmd

            BooleanArgumentFlag

            Since: 1.4.0

            A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

            Example

            class Foo {
                public function bar($flag = true) {
                }
            }

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

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

                    $res = new EasyRdf\Resource($uri);
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '443', column '30').
            Open

                        return array(new VocabularyCategory($this, null));
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '239', column '31').
            Open

                        $serialiser = new EasyRdf\Serialiser\JsonLd();
            Severity: Minor
            Found in src/model/Model.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 getVocabularyList has a boolean flag argument $categories, which is a certain sign of a Single Responsibility Principle violation.
            Open

                public function getVocabularyList($categories = true, $shortname = false)
            Severity: Minor
            Found in src/model/Model.php by phpmd

            BooleanArgumentFlag

            Since: 1.4.0

            A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

            Example

            class Foo {
                public function bar($flag = true) {
                }
            }

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

            Missing class import via use statement (line '473', column '19').
            Open

                    throw new ValueError("Vocabulary id '$vocid' not found in configuration.");
            Severity: Minor
            Found in src/model/Model.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

            Missing class import via use statement (line '500', column '23').
            Open

                        throw new ValueError("no vocabulary found for graph $graph and endpoint $endpoint");
            Severity: Minor
            Found in src/model/Model.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

            Avoid using static access to class '\Composer\InstalledVersions' in method 'getVersion'.
            Open

            }
            Severity: Minor
            Found in src/model/Model.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

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

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

                    } else {
                        $retform = 'rdfxml';
                        $serialiser = new EasyRdf\Serialiser\RdfXml();
                    }
            Severity: Minor
            Found in src/model/Model.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

            Avoid using static access to class 'EasyRdf\RdfNamespace' in method 'getVocabularies'.
            Open

                                if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { // if not already defined
            Severity: Minor
            Found in src/model/Model.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

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

            Avoid using static access to class 'EasyRdf\RdfNamespace' in method 'getVocabularies'.
            Open

                                    EasyRdf\RdfNamespace::set($prefix, $voc->getUriSpace());
            Severity: Minor
            Found in src/model/Model.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

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

            Avoid using static access to class 'EasyRdf\RdfNamespace' in method 'getTypes'.
            Open

                            $shorteneduri = EasyRdf\RdfNamespace::shorten($uri);
            Severity: Minor
            Found in src/model/Model.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

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

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

                    } else { // multi-vocabulary or global search
                        $voc = null;
                        $sparql = $this->getDefaultSparql();
                        // @TODO : in a global search showDeprecated will always be false and cannot be set globally
                    }
            Severity: Minor
            Found in src/model/Model.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 method searchConcepts uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                        } else {
                            try {
                                $hitvoc = $this->getVocabularyByGraph($hit['graph']);
                                $hit['vocab'] = $hitvoc->getId();
                            } catch (ValueError $e) {
            Severity: Minor
            Found in src/model/Model.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 method getVocabularyByGraph uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        throw new ValueError("no vocabulary found for graph $graph and endpoint $endpoint");
                    }
            Severity: Minor
            Found in src/model/Model.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

            Avoid using static access to class 'Punic\Language' in method 'getLanguages'.
            Open

                            $langlit = Punic\Language::getName($langcode, $lang);
            Severity: Minor
            Found in src/model/Model.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

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

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

                    } else { // APC not available, parse on every request
                        $resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout());
                    }
            Severity: Minor
            Found in src/model/Model.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 method searchConceptsAndInfo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        $arrayClass = null;
                        $sparql = $this->getDefaultSparql();
                    }
            Severity: Minor
            Found in src/model/Model.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 method disambiguateVocabulary uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                                    } else {
                                        // not found in preferred vocabulary, fall back to next method
                                        break;
                                    }
            Severity: Minor
            Found in src/model/Model.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 method getRDF uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        $sparql = $this->getDefaultSparql();
                        $arrayClass = null;
                        $vocabs = null;
                    }
            Severity: Minor
            Found in src/model/Model.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

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

                    foreach ($this->globalConfig->getLanguages() as $langcode => $locale) {
            Severity: Minor
            Found in src/model/Model.php by phpmd

            UnusedLocalVariable

            Since: 0.2

            Detects when a local variable is declared and/or assigned, but not used.

            Example

            class Foo {
                public function doSomething()
                {
                    $i = 5; // Unused
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

            TODO found
            Open

                        // @TODO : in a global search showDeprecated will always be false and cannot be set globally
            Severity: Minor
            Found in src/model/Model.php by fixme

            The parameter $config_filename is not named in camelCase.
            Open

                public function __construct(string $config_filename = "../../config.ttl")
                {
                    $this->resolver = new Resolver($this);
                    $this->globalConfig = new GlobalConfig($this, $config_filename);
                    $this->translator = null;
            Severity: Minor
            Found in src/model/Model.php by phpmd

            CamelCaseParameterName

            Since: 0.2

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

            Example

            class ClassName {
                public function doSomething($user_name) {
                }
            }

            Source

            The variable $config_filename is not named in camelCase.
            Open

                public function __construct(string $config_filename = "../../config.ttl")
                {
                    $this->resolver = new Resolver($this);
                    $this->globalConfig = new GlobalConfig($this, $config_filename);
                    $this->translator = null;
            Severity: Minor
            Found in src/model/Model.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