hnhdigital-os/php-linode-api

View on GitHub
src/foundation/ApiSearch.php

Summary

Maintainability
A
35 mins
Test Coverage

The class ApiSearch has 11 public methods. Consider refactoring ApiSearch to keep number of public methods under 10.
Open

class ApiSearch implements \Iterator, \Countable
{
    use ApiRequestTrait;

    /**
Severity: Minor
Found in src/foundation/ApiSearch.php by phpmd

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 get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function get()
    {
        // Return cached results for this page.
        if (isset($this->page_results[$this->current_page])) {
            $this->current_result = $this->page_results[$this->current_page];
Severity: Minor
Found in src/foundation/ApiSearch.php - About 35 mins 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 excessively long variable names like $endpoint_placeholders. Keep variable name length under 20.
Open

    public function __construct($endpoint, $endpoint_placeholders, $factory_settings = [])
Severity: Minor
Found in src/foundation/ApiSearch.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $result_records_per_page. Keep variable name length under 20.
Open

    private $result_records_per_page = 10;
Severity: Minor
Found in src/foundation/ApiSearch.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $endpoint_placeholders. Keep variable name length under 20.
Open

    protected $endpoint_placeholders;
Severity: Minor
Found in src/foundation/ApiSearch.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Blank line found at start of control structure
Open

        foreach ($current_result['data'] as $entry) {
Severity: Minor
Found in src/foundation/ApiSearch.php by phpcodesniffer

Line exceeds 120 characters; contains 130 characters
Open

            && ((($this->current_page - 1) * $this->result_records_per_page) + $this->current_record) < $this->result_total_count;
Severity: Minor
Found in src/foundation/ApiSearch.php by phpcodesniffer

There are no issues that match your filters.

Category
Status