Admidio/admidio

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

Summary

Maintainability
B
6 hrs
Test Coverage

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

    public function addElement(string $childElement, string $attrKey = '', string $attrValue = '', string $data = '', bool $selfClosing = false)
    {
        // if previous current element was not written to html string and the same child element is set
        // than this could be a call of parent class so do not reinitialize the current element
        if (!$this->currentElementDataWritten && $childElement === $this->currentElement) {
Severity: Minor
Found in adm_program/system/classes/HtmlElement.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 addElement has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addElement(string $childElement, string $attrKey = '', string $attrValue = '', string $data = '', bool $selfClosing = false)
    {
        // if previous current element was not written to html string and the same child element is set
        // than this could be a call of parent class so do not reinitialize the current element
        if (!$this->currentElementDataWritten && $childElement === $this->currentElement) {
Severity: Minor
Found in adm_program/system/classes/HtmlElement.php - About 1 hr to fix

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

        public function closeParentElement(string $parentElement): bool
        {
            // count entries in array
            $totalCount = count($this->arrParentElements);
    
    
    Severity: Minor
    Found in adm_program/system/classes/HtmlElement.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 addParentElement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addParentElement(string $parentElement, string $attrKey = '', string $attrValue = '')
        {
            // Only possible for child elements of the main element or nesting mode is active!
            if (!$this->nesting && $this->currentElement === $this->mainElement) {
                return;
    Severity: Minor
    Found in adm_program/system/classes/HtmlElement.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 addAttribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addAttribute(string $attrKey, string $attrValue, string $element = '')
        {
            if ($element === '') {
                $element = $this->currentElement;
            }
    Severity: Minor
    Found in adm_program/system/classes/HtmlElement.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 addElement has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function addElement(string $childElement, string $attrKey = '', string $attrValue = '', string $data = '', bool $selfClosing = false)
    Severity: Minor
    Found in adm_program/system/classes/HtmlElement.php - About 35 mins to fix

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

          public function addData($data, bool $selfClosing = false)
          {
              if ($selfClosing) {
                  $startTag = '<' . $this->currentElement . $this->getCurrentElementAttributesString();
                  $endTag   = '/>';
      Severity: Minor
      Found in adm_program/system/classes/HtmlElement.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