Admidio/admidio

View on GitHub
adm_program/system/classes/TableFolder.php

Summary

Maintainability
F
4 days
Test Coverage

File TableFolder.php has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
use Admidio\Exception;

/**
 * @brief Class manages access to database table adm_folders
Severity: Minor
Found in adm_program/system/classes/TableFolder.php - About 6 hrs to fix

    Function addAdditionalToFolderContents has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addAdditionalToFolderContents(array $completeFolder): array
        {
            global $gCurrentUser;
    
            // If user hasn't adminDocumentsFiles, don't add more data
    Severity: Minor
    Found in adm_program/system/classes/TableFolder.php - About 6 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

    TableFolder has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TableFolder extends TableAccess
    {
        /**
         * @var RolesRights|null Object with all roles that could view the current folder
         */
    Severity: Minor
    Found in adm_program/system/classes/TableFolder.php - About 3 hrs to fix

      Function getSubfoldersWithProperties has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getSubfoldersWithProperties(): array
          {
              global $gCurrentUser, $gValidLogin;
      
              // Get all subfolder of the current folder
      Severity: Minor
      Found in adm_program/system/classes/TableFolder.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 addAdditionalToFolderContents has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function addAdditionalToFolderContents(array $completeFolder): array
          {
              global $gCurrentUser;
      
              // If user hasn't adminDocumentsFiles, don't add more data
      Severity: Minor
      Found in adm_program/system/classes/TableFolder.php - About 1 hr to fix

        Method delete has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function delete(int $folderId = 0): bool
            {
                global $gLogger;
        
                $folId = (int)$this->getValue('fol_id');
        Severity: Minor
        Found in adm_program/system/classes/TableFolder.php - About 1 hr to fix

          Method getSubfoldersWithProperties has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getSubfoldersWithProperties(): array
              {
                  global $gCurrentUser, $gValidLogin;
          
                  // Get all subfolder of the current folder
          Severity: Minor
          Found in adm_program/system/classes/TableFolder.php - About 1 hr to fix

            Function addFolderOrFileToDatabase has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                public function addFolderOrFileToDatabase(string $newFolderFileName)
                {
                    $newFolderFileName = urldecode($newFolderFileName);
                    $newObjectPath = $this->getFullFolderPath() . '/' . $newFolderFileName;
                    $folderId = (int)$this->getValue('fol_id');
            Severity: Minor
            Found in adm_program/system/classes/TableFolder.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 getFilesWithProperties has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getFilesWithProperties(): array
                {
                    global $gCurrentUser;
            
                    $files = array();
            Severity: Minor
            Found in adm_program/system/classes/TableFolder.php - About 1 hr to fix

              Function getFolderForDownload has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getFolderForDownload(string $folderUuid): bool
                  {
                      global $gCurrentUser, $gCurrentOrgId, $gValidLogin;
              
                      if ($folderUuid !== '') {
              Severity: Minor
              Found in adm_program/system/classes/TableFolder.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 getFolderForDownload has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getFolderForDownload(string $folderUuid): bool
                  {
                      global $gCurrentUser, $gCurrentOrgId, $gValidLogin;
              
                      if ($folderUuid !== '') {
              Severity: Minor
              Found in adm_program/system/classes/TableFolder.php - About 1 hr to fix

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

                    public function addFolderOrFileToDatabase(string $newFolderFileName)
                    {
                        $newFolderFileName = urldecode($newFolderFileName);
                        $newObjectPath = $this->getFullFolderPath() . '/' . $newFolderFileName;
                        $folderId = (int)$this->getValue('fol_id');
                Severity: Minor
                Found in adm_program/system/classes/TableFolder.php - About 1 hr to fix

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

                      public function delete(int $folderId = 0): bool
                      {
                          global $gLogger;
                  
                          $folId = (int)$this->getValue('fol_id');
                  Severity: Minor
                  Found in adm_program/system/classes/TableFolder.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 getFilesWithProperties has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getFilesWithProperties(): array
                      {
                          global $gCurrentUser;
                  
                          $files = array();
                  Severity: Minor
                  Found in adm_program/system/classes/TableFolder.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

                  Method editRolesOnFolder has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      private function editRolesOnFolder(string $mode, string $rolesRightNameIntern, array $rolesArray, bool $recursive, int $folderId = 0)
                  Severity: Minor
                  Found in adm_program/system/classes/TableFolder.php - About 35 mins to fix

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

                        private function editRolesOnFolder(string $mode, string $rolesRightNameIntern, array $rolesArray, bool $recursive, int $folderId = 0)
                        {
                            if (count($rolesArray) === 0) {
                                return;
                            }
                    Severity: Minor
                    Found in adm_program/system/classes/TableFolder.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

                    There are no issues that match your filters.

                    Category
                    Status