luyadev/luya-module-cms

View on GitHub
src/Menu.php

Summary

Maintainability
D
1 day
Test Coverage
C
74%

Menu has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

class Menu extends Component implements \ArrayAccess, QueryOperatorFieldInterface
{
    use CacheableTrait;

    /**
Severity: Minor
Found in src/Menu.php - About 4 hrs to fix

    File Menu.php has 336 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace luya\cms;
    
    use luya\cms\menu\InjectItemInterface;
    Severity: Minor
    Found in src/Menu.php - About 4 hrs to fix

      Method loadWebsiteLanguageContainer has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function loadWebsiteLanguageContainer($langShortCode)
          {
              $hostName = $this->request->hostName;
              $cacheKey = $this->_cachePrefix.$hostName.$langShortCode;
      
      
      Severity: Minor
      Found in src/Menu.php - About 1 hr to fix

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

            private function resolveCurrent()
            {
                $requestPath = $this->request->get('path', null);
        
                if (empty($requestPath)) {
        Severity: Minor
        Found in src/Menu.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 resolveCurrent has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function resolveCurrent()
            {
                $requestPath = $this->request->get('path', null);
        
                if (empty($requestPath)) {
        Severity: Minor
        Found in src/Menu.php - About 1 hr to fix

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

              private function loadWebsiteLanguageContainer($langShortCode)
              {
                  $hostName = $this->request->hostName;
                  $cacheKey = $this->_cachePrefix.$hostName.$langShortCode;
          
          
          Severity: Minor
          Found in src/Menu.php - About 55 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 getLevelContainer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getLevelContainer($level, Item $baseItem = null): array|\luya\cms\menu\QueryIteratorFilter
              {
                  // define if the requested level is the root line (level 1) or not
                  $rootLine = ($level === 1) ? true : false;
                  // countdown the level (as we need the parent of the element to get the children
          Severity: Minor
          Found in src/Menu.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

          There are no issues that match your filters.

          Category
          Status