Kylob/Validator

View on GitHub

Showing 8 of 8 total issues

Function set has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

    public function set($field, $rules = '')
    {
        if (is_array($field)) {
            foreach ($field as $name => $rules) {
                if (is_numeric($name) && is_string($rules)) {
Severity: Minor
Found in src/Component.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 Component.php has 525 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace BootPress\Validator;

use BootPress\Page\Component as Page;
Severity: Major
Found in src/Component.php - About 1 day to fix

    Method set has 177 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function set($field, $rules = '')
        {
            if (is_array($field)) {
                foreach ($field as $name => $rules) {
                    if (is_numeric($name) && is_string($rules)) {
    Severity: Major
    Found in src/Component.php - About 7 hrs to fix

      Component has 42 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Component
      {
          /** @var callable[] Custom validation rules that you would like to apply. */
          public $rules = array();
      
      
      Severity: Minor
      Found in src/Component.php - About 5 hrs to fix

        Function certified has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function certified()
            {
                if (!is_null($this->submitted)) {
                    return $this->certified; // so we don't overwrite error messages
                }
        Severity: Minor
        Found in src/Component.php - About 3 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

        Function validate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            private function validate($value, $rule, $param)
            {
                if (in_array($rule, $this->reserved)) {
                    return array($value, null);
                }
        Severity: Minor
        Found in src/Component.php - About 2 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 certified has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function certified()
            {
                if (!is_null($this->submitted)) {
                    return $this->certified; // so we don't overwrite error messages
                }
        Severity: Minor
        Found in src/Component.php - About 1 hr to fix

          Method validate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function validate($value, $rule, $param)
              {
                  if (in_array($rule, $this->reserved)) {
                      return array($value, null);
                  }
          Severity: Minor
          Found in src/Component.php - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language