Method configTemplate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function configTemplate()
{
return [
'config'=>[
[
Method contactHue
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function contactHue($obj, $opts)
{
// Don't alert on resolve at this time
if ($obj['state'] == AlertState::RECOVERED) {
return true;
The method contactHue uses an else expression. Else is never necessary and you can simplify the code to work without else. Open
} else {
$device = device_by_id_cache($obj['device_id']); // for event logging
$hue_user = $opts['user'];
$url = $opts['bridge'] . "/api/$hue_user/groups/0/action";
$curl = curl_init();
- Read upRead up
- Exclude checks
Since: PHPMD 1.4.0
An if expression with an else branch is never necessary. You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements. To achieve this 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
}
}
}
The method contactHue uses an else expression. Else is never necessary and you can simplify the code to work without else. Open
} else {
d_echo('Hue bridge connection error: ' . serialize($ret));
return false;
}
- Read upRead up
- Exclude checks
Since: PHPMD 1.4.0
An if expression with an else branch is never necessary. You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements. To achieve this 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
}
}
}