The class ArubaInstant has 11 public methods. Consider refactoring ArubaInstant to keep number of public methods under 10. Open
class ArubaInstant extends OS implements
OSDiscovery,
ProcessorDiscovery,
WirelessApCountDiscovery,
WirelessApCountPolling,
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Function pollWirelessClients
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function pollWirelessClients(array $sensors)
{
$data = [];
if (! empty($sensors)) {
$device = $this->getDeviceArray();
- 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 discoverInstantRadio
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function discoverInstantRadio($type, $mib, $desc = '%s Radio %s')
{
$ai_mib = 'AI-AP-MIB';
$ai_sg_data = array_merge_recursive(
$this->getCacheTable('aiAPSerialNum', $ai_mib),
- 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 discoverWirelessClients
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function discoverWirelessClients()
{
$sensors = [];
$device = $this->getDeviceArray();
$ai_mib = 'AI-AP-MIB';
Method discoverInstantRadio
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function discoverInstantRadio($type, $mib, $desc = '%s Radio %s')
{
$ai_mib = 'AI-AP-MIB';
$ai_sg_data = array_merge_recursive(
$this->getCacheTable('aiAPSerialNum', $ai_mib),
Function discoverWirelessClients
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function discoverWirelessClients()
{
$sensors = [];
$device = $this->getDeviceArray();
$ai_mib = 'AI-AP-MIB';
- 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 pollWirelessClients
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function pollWirelessClients(array $sensors)
{
$data = [];
if (! empty($sensors)) {
$device = $this->getDeviceArray();
The method pollWirelessClients uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// version is lower than 8.4.0.0
if (! empty($sensors) && count($sensors) == 1) {
$ai_mib = 'AI-AP-MIB';
$client_data = $this->getCacheTable('aiClientMACAddress', $ai_mib);
- 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 discoverWirelessClients uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// version is lower than 8.4.0.0
// fetch the MAC addresses of currently connected clients, then count them to get an overall total
$client_data = $this->getCacheTable('aiClientMACAddress', $ai_mib);
- 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 pollWirelessClients uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$total_clients = count($client_data);
}
- 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
}
}
}