Kylob/BootPress

View on GitHub
src/Geo/Component.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

    public function convert($value, $unit = null)
    {
        if (is_null($unit)) {
            return array(
                'km' => $this->convert($value, 'km'),
Severity: Minor
Found in src/Geo/Component.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

Avoid too many return statements within this method.
Open

            return ($convert == 'Kilometers') ? $value * 1.60934 : $value * 0.868976; // else Nautical Miles
Severity: Major
Found in src/Geo/Component.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return ($convert == 'Kilometers') ? $value * 1.852 : $value * 1.15078; // else Miles
    Severity: Major
    Found in src/Geo/Component.php - About 30 mins to fix

      The CASE body must start on the line following the statement
      Open

                  case 'M': $convert = 'Miles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Each PHP statement must be on a line by itself
      Open

                  case 'K': $convert = 'Kilometers'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      The DEFAULT body must start on the line following the statement
      Open

                  default: return; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Terminating statement must be on a line by itself
      Open

                  case 'M': $convert = 'Miles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Terminating statement must be on a line by itself
      Open

                  case 'K': $convert = 'Kilometers'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      The CASE body must start on the line following the statement
      Open

                  case 'N': $convert = 'NauticalMiles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Terminating statement must be on a line by itself
      Open

                  case 'N': $convert = 'NauticalMiles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Terminating statement must be on a line by itself
      Open

                  default: return; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      The CASE body must start on the line following the statement
      Open

                  case 'K': $convert = 'Kilometers'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Each PHP statement must be on a line by itself
      Open

                  case 'M': $convert = 'Miles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Each PHP statement must be on a line by itself
      Open

                  case 'N': $convert = 'NauticalMiles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Each PHP statement must be on a line by itself
      Open

                  default: return; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Closing brace must be on a line by itself
      Open

                  case 'N': $convert = 'NauticalMiles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Closing brace must be on a line by itself
      Open

                  case 'K': $convert = 'Kilometers'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Closing brace must be on a line by itself
      Open

                  case 'M': $convert = 'Miles'; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      Closing brace must be on a line by itself
      Open

                  default: return; break;
      Severity: Minor
      Found in src/Geo/Component.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status