Passed
Push — master ( 1aba9a...2acbdd )
by William
04:40
created

OrderSearchComponent::getSearchConditions()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 11
c 1
b 0
f 0
nc 6
nop 1
dl 0
loc 22
ccs 12
cts 12
cp 1
crap 6
rs 9.2222
1
<?php
2
3
/* vim: set expandtab sw=4 ts=4 sts=4: */
4
/**
5
 * Order and search component handling generation of ordering and
6
 * searching conditions in loading data tables.
7
 *
8
 * phpMyAdmin Error reporting server
9
 * Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
10
 *
11
 * Licensed under The MIT License
12
 * For full copyright and license information, please see the LICENSE.txt
13
 * Redistributions of files must retain the above copyright notice.
14
 *
15
 * @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
16
 * @license   https://opensource.org/licenses/mit-license.php MIT License
17
 *
18
 * @see      https://www.phpmyadmin.net/
19
 */
20
21
namespace App\Controller\Component;
22
23
use Cake\Controller\Component;
24
25
/**
26
 * Github api component handling comunication with github.
27
 */
28
class OrderSearchComponent extends Component
29
{
30
    /**
31
     * Indexes are +1'ed because first column is of checkboxes
32
     * and hence it should be ingnored.
33
     *
34
     * @param string[] $aColumns The columns
35
     *
36
     * @return array
37
     */
38 2
    public function getSearchConditions($aColumns)
39
    {
40 2
        $searchConditions = ['OR' => []];
41 2
        $keys = array_keys($aColumns);
42 2
        $columnsCount = count($aColumns);
43
44 2
        if ($this->request->query('sSearch') != '') {
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

44
        if (/** @scrutinizer ignore-deprecated */ $this->request->query('sSearch') != '') {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

44
        if (/** @scrutinizer ignore-deprecated */ $this->request->query('sSearch') != '') {

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
45 1
            for ($i = 0; $i < $columnsCount; ++$i) {
46 1
                if ($this->request->query('bSearchable_' . ($i + 1)) == 'true') {
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

46
                if (/** @scrutinizer ignore-deprecated */ $this->request->query('bSearchable_' . ($i + 1)) == 'true') {

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

46
                if (/** @scrutinizer ignore-deprecated */ $this->request->query('bSearchable_' . ($i + 1)) == 'true') {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
47 1
                    $searchConditions['OR'][] = [$aColumns[$keys[$i]] . ' LIKE' => '%' . $this->request->query('sSearch') . '%'];
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
                    $searchConditions['OR'][] = [$aColumns[$keys[$i]] . ' LIKE' => '%' . /** @scrutinizer ignore-deprecated */ $this->request->query('sSearch') . '%'];

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Bug introduced by
Are you sure $this->request->query('sSearch') of type array|null|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
                    $searchConditions['OR'][] = [$aColumns[$keys[$i]] . ' LIKE' => '%' . /** @scrutinizer ignore-type */ $this->request->query('sSearch') . '%'];
Loading history...
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
                    $searchConditions['OR'][] = [$aColumns[$keys[$i]] . ' LIKE' => '%' . /** @scrutinizer ignore-deprecated */ $this->request->query('sSearch') . '%'];

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
48
                }
49
            }
50
        }
51
52
        /* Individual column filtering */
53 2
        for ($i = 0; $i < $columnsCount; ++$i) {
54 2
            if ($this->request->query('sSearch_' . ($i + 1)) != '') {
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

54
            if (/** @scrutinizer ignore-deprecated */ $this->request->query('sSearch_' . ($i + 1)) != '') {

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

54
            if (/** @scrutinizer ignore-deprecated */ $this->request->query('sSearch_' . ($i + 1)) != '') {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
55 1
                $searchConditions[] = [$aColumns[$keys[$i]] . ' LIKE' => $this->request->query('sSearch_' . ($i + 1))];
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
                $searchConditions[] = [$aColumns[$keys[$i]] . ' LIKE' => /** @scrutinizer ignore-deprecated */ $this->request->query('sSearch_' . ($i + 1))];

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
                $searchConditions[] = [$aColumns[$keys[$i]] . ' LIKE' => /** @scrutinizer ignore-deprecated */ $this->request->query('sSearch_' . ($i + 1))];

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
            }
57
        }
58
59 2
        return $searchConditions;
60
    }
61
62
    /**
63
     * @param string[] $aColumns The columns
64
     *
65
     * @return array
66
     */
67 2
    public function getOrder($aColumns)
68
    {
69 2
        if ($this->request->query('iSortCol_0') != null) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->request->query('iSortCol_0') of type array|null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

69
        if (/** @scrutinizer ignore-deprecated */ $this->request->query('iSortCol_0') != null) {

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

69
        if (/** @scrutinizer ignore-deprecated */ $this->request->query('iSortCol_0') != null) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
70 1
            $order = [];
71
            //Seems like we need to sort with only one column each time, so no need to loop
72 1
            $sort_column_index = intval($this->request->query('iSortCol_0'));
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

72
            $sort_column_index = intval(/** @scrutinizer ignore-deprecated */ $this->request->query('iSortCol_0'));

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

72
            $sort_column_index = intval(/** @scrutinizer ignore-deprecated */ $this->request->query('iSortCol_0'));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
73
74 1
            $keys = array_keys($aColumns);
75
76 1
            if ($sort_column_index > 0
77 1
                && $this->request->query('bSortable_' . $sort_column_index) == 'true'
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

77
                && /** @scrutinizer ignore-deprecated */ $this->request->query('bSortable_' . $sort_column_index) == 'true'

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

77
                && /** @scrutinizer ignore-deprecated */ $this->request->query('bSortable_' . $sort_column_index) == 'true'

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
78
            ) {
79
                $order[$aColumns[$keys[$sort_column_index - 1]]] = $this->request->query('sSortDir_0');
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Http\ServerRequest::query() has been deprecated: 3.4.0 Use getQuery() or the PSR-7 getQueryParams() and withQueryParams() methods instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

79
                $order[$aColumns[$keys[$sort_column_index - 1]]] = /** @scrutinizer ignore-deprecated */ $this->request->query('sSortDir_0');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

79
                $order[$aColumns[$keys[$sort_column_index - 1]]] = /** @scrutinizer ignore-deprecated */ $this->request->query('sSortDir_0');

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
80
            }
81
82 1
            return $order;
83
        }
84
85 2
        return null;
86
    }
87
}
88