src/Geo/Component.php
Function convert
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public function convert($value, $unit = null)
{
if (is_null($unit)) {
return array(
'km' => $this->convert($value, 'km'),
- Read upRead up
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
Open
return ($convert == 'Kilometers') ? $value * 1.60934 : $value * 0.868976; // else Nautical Miles
Avoid too many return
statements within this method. Open
Open
return ($convert == 'Kilometers') ? $value * 1.852 : $value * 1.15078; // else Miles
The CASE body must start on the line following the statement Open
Open
case 'M': $convert = 'Miles'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
Open
case 'K': $convert = 'Kilometers'; break;
- Exclude checks
The DEFAULT body must start on the line following the statement Open
Open
default: return; break;
- Exclude checks
Terminating statement must be on a line by itself Open
Open
case 'M': $convert = 'Miles'; break;
- Exclude checks
Terminating statement must be on a line by itself Open
Open
case 'K': $convert = 'Kilometers'; break;
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'N': $convert = 'NauticalMiles'; break;
- Exclude checks
Terminating statement must be on a line by itself Open
Open
case 'N': $convert = 'NauticalMiles'; break;
- Exclude checks
Terminating statement must be on a line by itself Open
Open
default: return; break;
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'K': $convert = 'Kilometers'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
Open
case 'M': $convert = 'Miles'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
Open
case 'N': $convert = 'NauticalMiles'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
Open
default: return; break;
- Exclude checks
Closing brace must be on a line by itself Open
Open
case 'N': $convert = 'NauticalMiles'; break;
- Exclude checks
Closing brace must be on a line by itself Open
Open
case 'K': $convert = 'Kilometers'; break;
- Exclude checks
Closing brace must be on a line by itself Open
Open
case 'M': $convert = 'Miles'; break;
- Exclude checks
Closing brace must be on a line by itself Open
Open
default: return; break;
- Exclude checks