| Conditions | 1 |
| Paths | 1 |
| Total Lines | 129 |
| Code Lines | 74 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 22 | public function filterDataProvider(): array |
||
| 23 | { |
||
| 24 | return [ |
||
| 25 | 'Equals' => [ |
||
| 26 | new Equals('test', 42), |
||
| 27 | ['=', 'test', 42], |
||
| 28 | ], |
||
| 29 | 'In' => [ |
||
| 30 | new In('test', [1, 2, 3]), |
||
| 31 | ['in', 'test', [1, 2, 3]], |
||
| 32 | ], |
||
| 33 | 'GreaterThan' => [ |
||
| 34 | new GreaterThan('test', 42), |
||
| 35 | ['>', 'test', 42], |
||
| 36 | ], |
||
| 37 | 'GreaterThanOrEqual' => [ |
||
| 38 | new GreaterThanOrEqual('test', 42), |
||
| 39 | ['>=', 'test', 42], |
||
| 40 | ], |
||
| 41 | 'LessThan' => [ |
||
| 42 | new LessThan('test', 42), |
||
| 43 | ['<', 'test', 42], |
||
| 44 | ], |
||
| 45 | 'LessThanOrEqual' => [ |
||
| 46 | new LessThanOrEqual('test', 42), |
||
| 47 | ['<=', 'test', 42], |
||
| 48 | ], |
||
| 49 | 'Like' => [ |
||
| 50 | new Like('test', '42'), |
||
| 51 | ['like', 'test', '42'], |
||
| 52 | ], |
||
| 53 | 'Not' => [ |
||
| 54 | new Not(new Equals('test', 42)), |
||
| 55 | ['not', ['=', 'test', 42]], |
||
| 56 | ], |
||
| 57 | 'Any' => [ |
||
| 58 | new Any( |
||
| 59 | new Equals('test', 1), |
||
| 60 | new Equals('test', 2) |
||
| 61 | ), |
||
| 62 | ['or', [ |
||
| 63 | ['=', 'test', 1], |
||
| 64 | ['=', 'test', 2], |
||
| 65 | ]] |
||
| 66 | ], |
||
| 67 | 'All' => [ |
||
| 68 | new All( |
||
| 69 | new LessThan('test', 3), |
||
| 70 | new GreaterThan('test', 2) |
||
| 71 | ), |
||
| 72 | ['and', [ |
||
| 73 | ['<', 'test', 3], |
||
| 74 | ['>', 'test', 2], |
||
| 75 | ]] |
||
| 76 | ], |
||
| 77 | 'NestedGroup' => [ |
||
| 78 | new All( |
||
| 79 | new Equals('test', 42), |
||
| 80 | new Any( |
||
| 81 | new Equals('test', 1), |
||
| 82 | new Equals('test', 2) |
||
| 83 | ) |
||
| 84 | ), |
||
| 85 | [ |
||
| 86 | 'and', |
||
| 87 | [ |
||
| 88 | ['=', 'test', 42], |
||
| 89 | [ |
||
| 90 | 'or', |
||
| 91 | [ |
||
| 92 | ['=', 'test', 1], |
||
| 93 | ['=', 'test', 2], |
||
| 94 | ] |
||
| 95 | ] |
||
| 96 | ] |
||
| 97 | ] |
||
| 98 | ], |
||
| 99 | 'withFiltersArrayAll' => [ |
||
| 100 | (new All())->withFiltersArray([ |
||
| 101 | ['<', 'test', 3], |
||
| 102 | ]), |
||
| 103 | [ |
||
| 104 | 'and', |
||
| 105 | [ |
||
| 106 | ['<', 'test', 3], |
||
| 107 | ], |
||
| 108 | ] |
||
| 109 | ], |
||
| 110 | 'withFiltersArrayAny' => [ |
||
| 111 | (new Any())->withFiltersArray([ |
||
| 112 | ['<', 'test1', 3], |
||
| 113 | new Equals('test2', 33), |
||
| 114 | ]), |
||
| 115 | [ |
||
| 116 | 'or', |
||
| 117 | [ |
||
| 118 | ['<', 'test1', 3], |
||
| 119 | ['=', 'test2', 33], |
||
| 120 | ], |
||
| 121 | ], |
||
| 122 | ], |
||
| 123 | 'withFiltersArrayNestedGroup' => [ |
||
| 124 | (new All())->withFiltersArray([ |
||
| 125 | ['<', 'test', 3], |
||
| 126 | [ |
||
| 127 | 'and', |
||
| 128 | [ |
||
| 129 | ['>', 'test2', 99], |
||
| 130 | ] |
||
| 131 | ], |
||
| 132 | ]), |
||
| 133 | [ |
||
| 134 | 'and', |
||
| 135 | [ |
||
| 136 | ['<', 'test', 3], |
||
| 137 | [ |
||
| 138 | 'and', |
||
| 139 | [ |
||
| 140 | ['>', 'test2', 99], |
||
| 141 | ], |
||
| 142 | ], |
||
| 143 | ], |
||
| 144 | ], |
||
| 145 | ], |
||
| 146 | 'withFiltersArrayEmpty' => [ |
||
| 147 | (new All())->withFiltersArray([]), |
||
| 148 | [ |
||
| 149 | 'and', |
||
| 150 | [], |
||
| 151 | ], |
||
| 191 |