src/ELearn/Searcher.php

Summary

Maintainability
B
5 hrs
Test Coverage

Function filter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    function filter()
    {
        if (strlen($this->where_clause) > 0) {
            return $this->where_clause;
        }
Severity: Minor
Found in src/ELearn/Searcher.php - About 1 hr 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

Function setFromRequest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    function setFromRequest($request)
    {
        if (isset($request->REQUEST['_px_q'])) {
            $this->search_string = $request->REQUEST['_px_q'];
        }
Severity: Minor
Found in src/ELearn/Searcher.php - About 45 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

Function render_array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    function render_array()
    {
        if (count($this->sort_order) != 2) {
            $order = null;
        } else {
Severity: Minor
Found in src/ELearn/Searcher.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

Function render_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    function render_object()
    {
        if (count($this->sort_order) != 2) {
            $order = null;
        } else {
Severity: Minor
Found in src/ELearn/Searcher.php - About 25 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

The method setFromRequest() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    function setFromRequest($request)
    {
        if (isset($request->REQUEST['_px_q'])) {
            $this->search_string = $request->REQUEST['_px_q'];
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

Missing class import via use statement (line '261', column '28').
Open

            $lastsql = new Pluf_SQL();
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '163', column '24').
Open

            $sql = new Pluf_SQL($request->REQUEST['_px_fk'] . '=%s', $request->REQUEST['_px_fv']);
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '264', column '28').
Open

                $sql = new Pluf_SQL();
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '266', column '34').
Open

                    $sqlor = new Pluf_SQL();
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method render_object uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $s = $this->sort_order[1];
            if (in_array($this->sort_order[0], $this->sort_reverse_order)) {
                $s = ($s == 'ASC') ? 'DESC' : 'ASC';
            }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

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 render_object uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $items = $this->items;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

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 render_array uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $s = $this->sort_order[1];
            if (in_array($this->sort_order[0], $this->sort_reverse_order)) {
                $s = ($s == 'ASC') ? 'DESC' : 'ASC';
            }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

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 setFromRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $this->forced_where = $sql;
            }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

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 render_array uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $items = $this->items;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

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

Define a constant instead of duplicating this literal "_px_fv" 3 times.
Open

        if (isset($request->REQUEST['_px_fk']) and in_array($request->REQUEST['_px_fk'], $this->list_filters) and isset($request->REQUEST['_px_fv'])) {
Severity: Critical
Found in src/ELearn/Searcher.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Add curly braces around the nested statement(s).
Open

            if (strlen($this->where_clause) == 0)
Severity: Critical
Found in src/ELearn/Searcher.php by sonar-php

While not technically incorrect, the omission of curly braces can be misleading, and may lead to the introduction of errors during maintenance.

Noncompliant Code Example

if (condition)  // Noncompliant
  executeSomething();

Compliant Solution

if (condition) {
  executeSomething();
}

See

  • MISRA C:2004, 14.8 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C:2004, 14.9 - An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C++:2008, 6-3-1 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C++:2008, 6-4-1 - An if (condition) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C:2012, 15.6 - The body of an iteration-statement or a selection-statement shall be a compound-statement
  • CERT, EXP19-C. - Use braces for the body of an if, for, or while statement
  • CERT, EXP52-J. - Use braces for the body of an if, for, or while statement

Define a constant instead of duplicating this literal "_px_fk" 4 times.
Open

        if (isset($request->REQUEST['_px_fk']) and in_array($request->REQUEST['_px_fk'], $this->list_filters) and isset($request->REQUEST['_px_fv'])) {
Severity: Critical
Found in src/ELearn/Searcher.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Rename "$items" which has the same name as the field declared at line 34.
Open

            $items = $this->model->getList(array(
Severity: Major
Found in src/ELearn/Searcher.php by sonar-php

Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

Noncompliant Code Example

class Foo {
  public $myField;

  public function doSomething() {
    $myField = 0;
    ...
  }
}

See

Define a constant instead of duplicating this literal "_px_sk" 3 times.
Open

        if (isset($request->REQUEST['_px_sk']) and in_array($request->REQUEST['_px_sk'], $this->sort_fields)) {
Severity: Critical
Found in src/ELearn/Searcher.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Rename "$items" which has the same name as the field declared at line 34.
Open

            $items = $this->model->getList(array(
Severity: Major
Found in src/ELearn/Searcher.php by sonar-php

Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

Noncompliant Code Example

class Foo {
  public $myField;

  public function doSomething() {
    $myField = 0;
    ...
  }
}

See

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

            $sql = new Pluf_SQL($request->REQUEST['_px_fk'] . '=%s', $request->REQUEST['_px_fv']);
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Call to method __construct from undeclared class \Pluf_SQL
Open

                    $sqlor = new Pluf_SQL();
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Return type of render_object() is undeclared type \unknown
Open

    function render_object()
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

            $this->search_string = $request->REQUEST['_px_q'];
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Call to method __construct from undeclared class \Pluf_SQL
Open

                $sql = new Pluf_SQL();
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Call to method SAnd from undeclared class \Pluf_SQL
Open

                $lastsql->SAnd($this->forced_where);
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

        if (isset($request->REQUEST['_px_q'])) {
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

            $this->sort_order[0] = $request->REQUEST['_px_sk'];
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

            if (isset($request->REQUEST['_px_so']) and ($request->REQUEST['_px_so'] == 'd')) {
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

        if (isset($request->REQUEST['_px_fk']) and in_array($request->REQUEST['_px_fk'], $this->list_filters) and isset($request->REQUEST['_px_fv'])) {
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Call to method __construct from undeclared class \Pluf_SQL
Open

            $sql = new Pluf_SQL($request->REQUEST['_px_fk'] . '=%s', $request->REQUEST['_px_fv']);
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Call to method __construct from undeclared class \Pluf_SQL
Open

            $lastsql = new Pluf_SQL();
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Call to method gen from undeclared class \Pluf_SQL
Open

            $this->where_clause = $lastsql->gen();
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

                $request->REQUEST['_px_fk'],
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Call to method keywords from undeclared class \Pluf_SQL
Open

            $keywords = $lastsql->keywords($this->search_string);
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

                $request->REQUEST['_px_fv']
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Call to method SAnd from undeclared class \Pluf_SQL
Open

                $lastsql->SAnd($sql);
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Call to method SAnd from undeclared class \Pluf_SQL
Open

                $this->forced_where->SAnd($sql);
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Saw unextractable annotation for comment '* @param'
Open

     * @param
Severity: Info
Found in src/ELearn/Searcher.php by phan

Call to method Q from undeclared class \Pluf_SQL
Open

                    $sqlor->Q($field . ' LIKE %s', '%' . $key . '%');
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Saw a token Phan may have failed to parse after '* @return Array.': after Array, saw '.'
Open

     * @return Array.
Severity: Info
Found in src/ELearn/Searcher.php by phan

Returning type null but filter() is declared to return string
Open

        return $this->where_clause;
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
Open

        if (isset($request->REQUEST['_px_sk']) and in_array($request->REQUEST['_px_sk'], $this->sort_fields)) {
Severity: Minor
Found in src/ELearn/Searcher.php by phan

Call to method SOr from undeclared class \Pluf_SQL
Open

                    $sql->SOr($sqlor);
Severity: Critical
Found in src/ELearn/Searcher.php by phan

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        if (count($this->sort_order) != 2) {
            $order = null;
        } else {
            $s = $this->sort_order[1];
            if (in_array($this->sort_order[0], $this->sort_reverse_order)) {
Severity: Major
Found in src/ELearn/Searcher.php and 1 other location - About 1 hr to fix
src/ELearn/Searcher.php on lines 226..234

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 105.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        if (count($this->sort_order) != 2) {
            $order = null;
        } else {
            $s = $this->sort_order[1];
            if (in_array($this->sort_order[0], $this->sort_reverse_order)) {
Severity: Major
Found in src/ELearn/Searcher.php and 1 other location - About 1 hr to fix
src/ELearn/Searcher.php on lines 190..198

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 105.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class ELearn_Searcher
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

The property $list_filters is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $sort_fields is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $sort_reverse_order is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

Avoid variables with short names like $s. Configured minimum length is 3.
Open

            $s = $this->sort_order[1];
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

The property $forced_where is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

Avoid variables with short names like $s. Configured minimum length is 3.
Open

            $s = $this->sort_order[1];
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

The parameter $search_fields is not named in camelCase.
Open

    function __construct($model = null, $search_fields = array())
    {
        $this->model = $model;
        $this->configure($search_fields);
    }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The property $active_list_filter is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $model_view is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $search_string is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The class ELearn_Searcher is not named in CamelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

The property $search_fields is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $where_clause is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The parameter $sort_fields is not named in camelCase.
Open

    function configure($search_fields = array(), $sort_fields = array())
    {
        if (is_array($search_fields)) {
            $this->search_fields = $search_fields;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The property $sort_order is not named in camelCase.
Open

class ELearn_Searcher
{

    /**
     * این مدل داده‌ای جستجوگر خواهد شد.
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The parameter $search_fields is not named in camelCase.
Open

    function configure($search_fields = array(), $sort_fields = array())
    {
        if (is_array($search_fields)) {
            $this->search_fields = $search_fields;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

Visibility must be declared on method "setFromRequest"
Open

    function setFromRequest($request)
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Visibility must be declared on method "configure"
Open

    function configure($search_fields = array(), $sort_fields = array())
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Visibility must be declared on method "__construct"
Open

    function __construct($model = null, $search_fields = array())
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Visibility must be declared on method "render_array"
Open

    function render_array()
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Method name "ELearn_Searcher::render_array" is not in camel caps format
Open

    function render_array()
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Method name "ELearn_Searcher::render_object" is not in camel caps format
Open

    function render_object()
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Expected 1 blank line at end of file; 2 found
Open

}
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Visibility must be declared on method "filter"
Open

    function filter()
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Visibility must be declared on method "render_object"
Open

    function render_object()
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Line exceeds 120 characters; contains 138 characters
Open

     * این پارامترها برای ایجاد یک فهرست از داده‌ها به کار گرفته می‌شوند. تمام
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Line exceeds 120 characters; contains 136 characters
Open

     * علاوه بر این داده‌هایی که از پایگاه داده به دست آمده اند به صورت مستقیم
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Line exceeds 120 characters; contains 128 characters
Open

     * آرایه ایجاد شده هیچ محدودیتی ندارد و شامل تمام مواردی است که قبل در
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Line exceeds 120 characters; contains 129 characters
Open

     * این روش برای استفاده از داده‌ها در ساختارهایی مانند JSON بسیار مناسب
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Line exceeds 120 characters; contains 151 characters
Open

        if (isset($request->REQUEST['_px_fk']) and in_array($request->REQUEST['_px_fk'], $this->list_filters) and isset($request->REQUEST['_px_fv'])) {
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Line exceeds 120 characters; contains 136 characters
Open

     * نمایشی از مدل داده‌ای را تعیین می‌کند که باید در این صفحه بندی استفاده
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Line exceeds 120 characters; contains 135 characters
Open

     * با استفاده از این فراخوانی می‌توان به فهرست تمام موجودیت‌ها دست یافت.
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Inline control structures are not allowed
Open

            if (strlen($this->where_clause) == 0)
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Whitespace found at end of line
Open

     *            
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Whitespace found at end of line
Open

 * @date 1396 
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

Class name "ELearn_Searcher" is not in camel caps format
Open

class ELearn_Searcher
Severity: Minor
Found in src/ELearn/Searcher.php by phpcodesniffer

The variable $search_fields is not named in camelCase.
Open

    function configure($search_fields = array(), $sort_fields = array())
    {
        if (is_array($search_fields)) {
            $this->search_fields = $search_fields;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $search_fields is not named in camelCase.
Open

    function __construct($model = null, $search_fields = array())
    {
        $this->model = $model;
        $this->configure($search_fields);
    }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $sort_fields is not named in camelCase.
Open

    function configure($search_fields = array(), $sort_fields = array())
    {
        if (is_array($search_fields)) {
            $this->search_fields = $search_fields;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $sort_fields is not named in camelCase.
Open

    function configure($search_fields = array(), $sort_fields = array())
    {
        if (is_array($search_fields)) {
            $this->search_fields = $search_fields;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $search_fields is not named in camelCase.
Open

    function configure($search_fields = array(), $sort_fields = array())
    {
        if (is_array($search_fields)) {
            $this->search_fields = $search_fields;
        }
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method render_object is not named in camelCase.
Open

    function render_object()
    {
        if (count($this->sort_order) != 2) {
            $order = null;
        } else {
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method render_array is not named in camelCase.
Open

    function render_array()
    {
        if (count($this->sort_order) != 2) {
            $order = null;
        } else {
Severity: Minor
Found in src/ELearn/Searcher.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status