Admidio/admidio

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

Summary

Maintainability
F
5 days
Test Coverage

Function getHtmlValue has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

    public function getHtmlValue(string $fieldNameIntern, $value, string $value2 = '')
    {
        global $gSettingsManager, $gL10n;

        if (!array_key_exists($fieldNameIntern, $this->mProfileFields)) {
Severity: Minor
Found in adm_program/system/classes/ProfileFields.php - About 1 day 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 setValue has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    public function setValue(string $fieldNameIntern, $fieldValue, bool $checkValue = true): bool
    {
        global $gSettingsManager, $gL10n;

        if (!array_key_exists($fieldNameIntern, $this->mProfileFields)) {
Severity: Minor
Found in adm_program/system/classes/ProfileFields.php - About 1 day 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

File ProfileFields.php has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
use Admidio\Exception;

/**
 * @brief Reads the user fields structure out of database and give access to it
Severity: Minor
Found in adm_program/system/classes/ProfileFields.php - About 6 hrs to fix

    Function getValue has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getValue(string $fieldNameIntern, string $format = '')
        {
            $value = '';
    
            // exists a profile field with that name ?
    Severity: Minor
    Found in adm_program/system/classes/ProfileFields.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

    Method getHtmlValue has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getHtmlValue(string $fieldNameIntern, $value, string $value2 = '')
        {
            global $gSettingsManager, $gL10n;
    
            if (!array_key_exists($fieldNameIntern, $this->mProfileFields)) {
    Severity: Major
    Found in adm_program/system/classes/ProfileFields.php - About 4 hrs to fix

      Method setValue has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function setValue(string $fieldNameIntern, $fieldValue, bool $checkValue = true): bool
          {
              global $gSettingsManager, $gL10n;
      
              if (!array_key_exists($fieldNameIntern, $this->mProfileFields)) {
      Severity: Major
      Found in adm_program/system/classes/ProfileFields.php - About 4 hrs to fix

        ProfileFields has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ProfileFields
        {
            /**
             * @var Database An object of the class Database for communication with the database
             */
        Severity: Minor
        Found in adm_program/system/classes/ProfileFields.php - About 2 hrs to fix

          Method getValue has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getValue(string $fieldNameIntern, string $format = '')
              {
                  $value = '';
          
                  // exists a profile field with that name ?
          Severity: Minor
          Found in adm_program/system/classes/ProfileFields.php - About 1 hr to fix

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

                public function readUserData(int $userId, int $organizationId)
                {
                    if (count($this->mProfileFields) === 0) {
                        $this->readProfileFields($organizationId);
                    }
            Severity: Minor
            Found in adm_program/system/classes/ProfileFields.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 saveUserData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function saveUserData(int $userId)
                {
                    $this->db->startTransaction();
            
                    foreach ($this->mUserData as $value) {
            Severity: Minor
            Found in adm_program/system/classes/ProfileFields.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 isVisible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function isVisible(string $fieldNameIntern, bool $allowedToEditProfile = false): bool
                {
                    if (!array_key_exists($fieldNameIntern, $this->mProfileFields)) {
                        return false;
                    }
            Severity: Minor
            Found in adm_program/system/classes/ProfileFields.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