| Conditions | 1 |
| Paths | 1 |
| Total Lines | 195 |
| 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 |
||
| 93 | public function providerForTestGetPermissionsCriterion() |
||
| 94 | { |
||
| 95 | $criterionMock = $this->createMock(Criterion::class); |
||
| 96 | $limitationMock = $this |
||
| 97 | ->getMockBuilder(APILimitation::class) |
||
| 98 | ->getMockForAbstractClass(); |
||
| 99 | $limitationMock |
||
| 100 | ->expects($this->any()) |
||
| 101 | ->method('getIdentifier') |
||
| 102 | ->will($this->returnValue('limitationIdentifier')); |
||
| 103 | |||
| 104 | $policy1 = new Policy(array('limitations' => array($limitationMock))); |
||
| 105 | $policy2 = new Policy(array('limitations' => array($limitationMock, $limitationMock))); |
||
| 106 | |||
| 107 | return array( |
||
| 108 | array( |
||
| 109 | $criterionMock, |
||
| 110 | 1, |
||
| 111 | array( |
||
| 112 | array( |
||
| 113 | 'limitation' => null, |
||
| 114 | 'policies' => array($policy1), |
||
| 115 | ), |
||
| 116 | ), |
||
| 117 | $criterionMock, |
||
| 118 | ), |
||
| 119 | array( |
||
| 120 | $criterionMock, |
||
| 121 | 2, |
||
| 122 | array( |
||
| 123 | array( |
||
| 124 | 'limitation' => null, |
||
| 125 | 'policies' => array($policy1, $policy1), |
||
| 126 | ), |
||
| 127 | ), |
||
| 128 | new Criterion\LogicalOr(array($criterionMock, $criterionMock)), |
||
| 129 | ), |
||
| 130 | array( |
||
| 131 | $criterionMock, |
||
| 132 | 0, |
||
| 133 | array( |
||
| 134 | array( |
||
| 135 | 'limitation' => null, |
||
| 136 | 'policies' => array(new Policy(array('limitations' => '*')), $policy1), |
||
| 137 | ), |
||
| 138 | ), |
||
| 139 | false, |
||
| 140 | ), |
||
| 141 | array( |
||
| 142 | $criterionMock, |
||
| 143 | 0, |
||
| 144 | array( |
||
| 145 | array( |
||
| 146 | 'limitation' => null, |
||
| 147 | 'policies' => array(new Policy(array('limitations' => array())), $policy1), |
||
| 148 | ), |
||
| 149 | ), |
||
| 150 | false, |
||
| 151 | ), |
||
| 152 | array( |
||
| 153 | $criterionMock, |
||
| 154 | 2, |
||
| 155 | array( |
||
| 156 | array( |
||
| 157 | 'limitation' => null, |
||
| 158 | 'policies' => array($policy2), |
||
| 159 | ), |
||
| 160 | ), |
||
| 161 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
| 162 | ), |
||
| 163 | array( |
||
| 164 | $criterionMock, |
||
| 165 | 3, |
||
| 166 | array( |
||
| 167 | array( |
||
| 168 | 'limitation' => null, |
||
| 169 | 'policies' => array($policy1, $policy2), |
||
| 170 | ), |
||
| 171 | ), |
||
| 172 | new Criterion\LogicalOr( |
||
| 173 | array( |
||
| 174 | $criterionMock, |
||
| 175 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
| 176 | ) |
||
| 177 | ), |
||
| 178 | ), |
||
| 179 | array( |
||
| 180 | $criterionMock, |
||
| 181 | 2, |
||
| 182 | array( |
||
| 183 | array( |
||
| 184 | 'limitation' => null, |
||
| 185 | 'policies' => array($policy1), |
||
| 186 | ), |
||
| 187 | array( |
||
| 188 | 'limitation' => null, |
||
| 189 | 'policies' => array($policy1), |
||
| 190 | ), |
||
| 191 | ), |
||
| 192 | new Criterion\LogicalOr(array($criterionMock, $criterionMock)), |
||
| 193 | ), |
||
| 194 | array( |
||
| 195 | $criterionMock, |
||
| 196 | 3, |
||
| 197 | array( |
||
| 198 | array( |
||
| 199 | 'limitation' => null, |
||
| 200 | 'policies' => array($policy1), |
||
| 201 | ), |
||
| 202 | array( |
||
| 203 | 'limitation' => null, |
||
| 204 | 'policies' => array($policy1, $policy1), |
||
| 205 | ), |
||
| 206 | ), |
||
| 207 | new Criterion\LogicalOr(array($criterionMock, $criterionMock, $criterionMock)), |
||
| 208 | ), |
||
| 209 | array( |
||
| 210 | $criterionMock, |
||
| 211 | 3, |
||
| 212 | array( |
||
| 213 | array( |
||
| 214 | 'limitation' => null, |
||
| 215 | 'policies' => array($policy2), |
||
| 216 | ), |
||
| 217 | array( |
||
| 218 | 'limitation' => null, |
||
| 219 | 'policies' => array($policy1), |
||
| 220 | ), |
||
| 221 | ), |
||
| 222 | new Criterion\LogicalOr( |
||
| 223 | array( |
||
| 224 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
| 225 | $criterionMock, |
||
| 226 | ) |
||
| 227 | ), |
||
| 228 | ), |
||
| 229 | array( |
||
| 230 | $criterionMock, |
||
| 231 | 2, |
||
| 232 | array( |
||
| 233 | array( |
||
| 234 | 'limitation' => $limitationMock, |
||
| 235 | 'policies' => array($policy1), |
||
| 236 | ), |
||
| 237 | ), |
||
| 238 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
| 239 | ), |
||
| 240 | array( |
||
| 241 | $criterionMock, |
||
| 242 | 4, |
||
| 243 | array( |
||
| 244 | array( |
||
| 245 | 'limitation' => $limitationMock, |
||
| 246 | 'policies' => array($policy1), |
||
| 247 | ), |
||
| 248 | array( |
||
| 249 | 'limitation' => $limitationMock, |
||
| 250 | 'policies' => array($policy1), |
||
| 251 | ), |
||
| 252 | ), |
||
| 253 | new Criterion\LogicalOr( |
||
| 254 | array( |
||
| 255 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
| 256 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
| 257 | ) |
||
| 258 | ), |
||
| 259 | ), |
||
| 260 | array( |
||
| 261 | $criterionMock, |
||
| 262 | 1, |
||
| 263 | array( |
||
| 264 | array( |
||
| 265 | 'limitation' => $limitationMock, |
||
| 266 | 'policies' => array(new Policy(array('limitations' => '*'))), |
||
| 267 | ), |
||
| 268 | ), |
||
| 269 | $criterionMock, |
||
| 270 | ), |
||
| 271 | array( |
||
| 272 | $criterionMock, |
||
| 273 | 2, |
||
| 274 | array( |
||
| 275 | array( |
||
| 276 | 'limitation' => $limitationMock, |
||
| 277 | 'policies' => array(new Policy(array('limitations' => '*'))), |
||
| 278 | ), |
||
| 279 | array( |
||
| 280 | 'limitation' => $limitationMock, |
||
| 281 | 'policies' => array(new Policy(array('limitations' => '*'))), |
||
| 282 | ), |
||
| 283 | ), |
||
| 284 | new Criterion\LogicalOr(array($criterionMock, $criterionMock)), |
||
| 285 | ), |
||
| 286 | ); |
||
| 287 | } |
||
| 288 | |||
| 426 |