Showing 37 of 37 total issues
Method indexActionPost
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexActionPost() : array
{
$mapUrl = "https://www.openstreetmap.org/search?query=";
$lat = null;
$long = null;
Method indexActionGet
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexActionGet() : object
{
$title = "Weather";
$page = $this->di->get("page");
$lat = null;
Method indexActionPost
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexActionPost() : array
{
$ipAdr = $this->di->request->getPost("ip");
$mapUrl = "https://www.openstreetmap.org/search?query=";
$valid = $this->validateIp->validate($ipAdr);
Function indexActionPost
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function indexActionPost() : array
{
$mapUrl = "https://www.openstreetmap.org/search?query=";
$lat = null;
$long = null;
- 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
Function getData
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function getData(array $weather, string $option = "daily")
{
$count = count($weather);
$selected = [];
- 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
Method indexActionPost
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexActionPost() : array
{
$valid = null;
$type = null;
$host = null;
Method getData
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getData(array $weather, string $option = "daily")
{
$count = count($weather);
$selected = [];
Method indexActionGet
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexActionGet() : object
{
$title = "Geolocation";
$page = $this->di->get("page");
$ipAdr = $this->di->request->getGet("ip");
Function indexActionPost
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function indexActionPost() : array
{
$valid = null;
$type = null;
$host = null;
- 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
Method indexAction
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexAction() : object
{
$title = "Validate IP";
$valid = null;
$type = null;
Function indexAction
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function indexAction() : object
{
$title = "Validate IP";
$valid = null;
$type = null;
- 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
Method multiCurlApi
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function multiCurlApi(array $urls) : array
{
$response = [];
if (count($urls) !== 0) {
Function indexActionGet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function indexActionGet() : object
{
$title = "Weather";
$page = $this->di->get("page");
$lat = null;
- 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
Function multiCurlApi
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function multiCurlApi(array $urls) : array
{
$response = [];
if (count($urls) !== 0) {
- 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
Function indexActionPost
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function indexActionPost() : array
{
$ipAdr = $this->di->request->getPost("ip");
$mapUrl = "https://www.openstreetmap.org/search?query=";
$valid = $this->validateIp->validate($ipAdr);
- 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
The method validate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return false;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method indexActionPost uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
http_response_code(400);
$json = [
"error" => [
"status" => http_response_code(),
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method indexActionPost uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$location = $this->weather->getLatLong($search);
$lat = $location["latitude"];
$long = $location["longitude"];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getUserIp uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$ipAdr = "X.X.X.X";
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method indexActionPost uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$valid = false;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}