Conditions | 1 |
Paths | 1 |
Total Lines | 92 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
11 | protected function rulesProvider() |
||
12 | { |
||
13 | return [ |
||
14 | [ |
||
15 | ['condition' => "and", 'rules' => [ |
||
16 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'equal', 'value' => 'joe'], |
||
17 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'not_equal', 'value' => 'bruce'] |
||
18 | ]], |
||
19 | ['(name = :p0 and name <> :p1)', [':p0' => 'joe', ':p1' => 'bruce']] |
||
20 | ], |
||
21 | [ |
||
22 | ['condition' => "and", 'rules' => [ |
||
23 | [ 'field' => 'id', 'type' => 'integer', 'operator' => 'in', 'value' => [1,2,3]], |
||
24 | [ 'field' => 'id', 'type' => 'integer', 'operator' => 'not_in', 'value' => [4,5]] |
||
25 | ]], |
||
26 | ['(id IN (:p0, :p1, :p2) and id NOT IN (:p3, :p4))', [':p0'=>1, ':p1'=>2, ':p2'=>3, ':p3'=>4, ':p4'=>5]] |
||
27 | ], |
||
28 | [ |
||
29 | ['condition' => "and", 'rules' => [ |
||
30 | [ 'field' => 'id', 'type' => 'integer', 'operator' => 'less', 'value' => 100], |
||
31 | [ 'field' => 'id', 'type' => 'integer', 'operator' => 'less_or_equal', 'value' => 50], |
||
32 | ]], |
||
33 | ['(id < :p0 and id <= :p1)', [':p0'=>100, ':p1'=>50]] |
||
34 | ], |
||
35 | [ |
||
36 | ['condition' => "and", 'rules' => [ |
||
37 | [ 'field' => 'id', 'type' => 'integer', 'operator' => 'greater', 'value' => 10], |
||
38 | [ 'field' => 'id', 'type' => 'integer', 'operator' => 'greater_or_equal', 'value' => 20], |
||
39 | ]], |
||
40 | ['(id > :p0 and id >= :p1)', [':p0'=>10, ':p1'=>20]] |
||
41 | ], |
||
42 | [ |
||
43 | ['condition' => "and", 'rules' => [ |
||
44 | [ 'field' => 'date', 'type' => 'date', 'operator' => 'between', 'value' => ['2015-01-01','2015-01-30']], |
||
45 | ]], |
||
46 | ['(date BETWEEN :p0 AND :p1)', [':p0'=>'2015-01-01', ':p1'=>'2015-01-30']] |
||
47 | ], |
||
48 | [ |
||
49 | ['condition' => "and", 'rules' => [ |
||
50 | [ 'field' => 'date', 'type' => 'date', 'operator' => 'not_between', 'value' => ['2015-01-01','2015-01-30']], |
||
51 | ]], |
||
52 | ['(date NOT BETWEEN :p0 AND :p1)', [':p0'=>'2015-01-01', ':p1'=>'2015-01-30']] |
||
53 | ], |
||
54 | [ |
||
55 | ['condition' => "and", 'rules' => [ |
||
56 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'begins_with', 'value' => 'joe'], |
||
57 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'not_begins_with', 'value' => 'bruce'], |
||
58 | ]], |
||
59 | ['(name LIKE :p0 and name NOT LIKE :p1)', [':p0'=>'joe%', ':p1'=> 'bruce%']] |
||
60 | ], |
||
61 | [ |
||
62 | ['condition' => "and", 'rules' => [ |
||
63 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'contains', 'value' => 'thomas'], |
||
64 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'not_contains', 'value' => 'paul'], |
||
65 | ]], |
||
66 | ['(name LIKE :p0 and name NOT LIKE :p1)', [':p0'=>'%thomas%', ':p1'=> '%paul%']] |
||
67 | ], |
||
68 | [ |
||
69 | ['condition' => "and", 'rules' => [ |
||
70 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'ends_with', 'value' => 'brian'], |
||
71 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'not_ends_with', 'value' => 'david'], |
||
72 | ]], |
||
73 | ['(name LIKE :p0 and name NOT LIKE :p1)', [':p0'=>'%brian', ':p1'=> '%david']] |
||
74 | ], |
||
75 | [ |
||
76 | ['condition' => "or", 'rules' => [ |
||
77 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'is_empty'], |
||
78 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'is_not_empty'], |
||
79 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'is_null'], |
||
80 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'is_not_null'], |
||
81 | ]], |
||
82 | ['(name = "" or name <> "" or name IS NULL or name IS NOT NULL)', []] |
||
83 | ], |
||
84 | [ |
||
85 | ['condition' => "and", 'rules' => [ |
||
86 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'begins_with', 'value' => 'kurt'], |
||
87 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'ends_with', 'value' => 'cobain'], |
||
88 | ['condition' => 'or', 'rules'=>[ |
||
89 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'equal', 'value' => 'joe'], |
||
90 | [ 'field' => 'name', 'type' => 'string', 'operator' => 'equal', 'value' => 'paul'], |
||
91 | ['condition' => 'and', 'rules'=>[ |
||
92 | [ 'field' => 'id', 'type' => 'integer', 'operator' => 'equal', 'value' => 10], |
||
93 | ]] |
||
94 | ]] |
||
95 | ]], |
||
96 | ['(name LIKE :p0 and name LIKE :p1 and (name = :p2 or name = :p3 or (id = :p4)))', [ |
||
97 | ':p0'=>'kurt%',':p1' =>'%cobain', ':p2' => 'joe', ':p3' => 'paul', ':p4' => 10 |
||
98 | ]] |
||
99 | ] |
||
100 | |||
101 | ]; |
||
102 | } |
||
103 | |||
121 |