strata-mvc/strata

View on GitHub
src/View/Helper/FormHelper.php

Summary

Maintainability
C
1 day
Test Coverage

File FormHelper.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Strata\View\Helper;

use Strata\Model\ModelEntity;
Severity: Minor
Found in src/View/Helper/FormHelper.php - About 3 hrs to fix

    FormHelper has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FormHelper extends Helper
    {
        /**
         * @var Strata\Controller\Request The active request
         */
    Severity: Minor
    Found in src/View/Helper/FormHelper.php - About 2 hrs to fix

      Method input has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function input($name, $options = array())
          {
              $options += array(
                  "type"  => "text",
                  "id"    => $this->id($name),
      Severity: Minor
      Found in src/View/Helper/FormHelper.php - About 1 hr to fix

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

            public function create($mixed = null, $options = array())
            {
                $this->request = Strata::router()->getCurrentController()->request;
        
                if (!is_null($mixed) && !in_array('Strata\\Model\\CustomPostType\\ModelEntity', class_parents($mixed))) {
        Severity: Minor
        Found in src/View/Helper/FormHelper.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 input has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function input($name, $options = array())
            {
                $options += array(
                    "type"  => "text",
                    "id"    => $this->id($name),
        Severity: Minor
        Found in src/View/Helper/FormHelper.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

        Avoid too many return statements within this method.
        Open

                        return $label . "\n" . $this->generateTextinput($options, $currentValue) . $errorHtml . "\n";
        Severity: Major
        Found in src/View/Helper/FormHelper.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $label . "\n" . $this->generateHidden($options, $currentValue) . $errorHtml . "\n";
          Severity: Major
          Found in src/View/Helper/FormHelper.php - About 30 mins to fix

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

                protected function getCurrentValue($key)
                {
                    $key = $this->removeBrackets($key);
            
                    if ($this->getConfig('method') === "GET" && $this->request->hasGet($key)) {
            Severity: Minor
            Found in src/View/Helper/FormHelper.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

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

                public function generateInlineErrors($postName)
                {
                    if (!is_null($this->associatedEntity)) {
                        $errors = (array)$this->associatedEntity->getValidationErrors();
            
            
            Severity: Minor
            Found in src/View/Helper/FormHelper.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