| Conditions | 1 |
| Paths | 1 |
| Total Lines | 62 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 46 | public function compareMethodArgumentsProvider(): array |
||
| 47 | { |
||
| 48 | $obj = new \stdClass(); |
||
| 49 | $obj->one = 1; |
||
| 50 | $obj->nine = 9; |
||
| 51 | |||
| 52 | $args = [ |
||
| 53 | 'integers: same value, +-' => [1, 5, -5], |
||
| 54 | 'integers: same value, -+' => [-1, -5, 5], |
||
| 55 | 'integers: same value, --' => [0, -5, -5], |
||
| 56 | 'integers: same value, ++' => [0, 5, 5], |
||
| 57 | 'integers: different value, +-' => [1, 90, -8], |
||
| 58 | 'integers: different value, -+' => [-1, -8, 90], |
||
| 59 | 'integers: different value, --' => [1, -8, -90], |
||
| 60 | 'integers: different value, ++' => [-1, 8, 90], |
||
| 61 | 'strings: same' => [0, 'world', 'world'], |
||
| 62 | 'strings: leading space, <' => [-1, 'world', 'world '], |
||
| 63 | 'strings: leading space, >' => [1, 'world ', 'world'], |
||
| 64 | 'strings: different chars, >' => [1, 'hola', 'hello'], |
||
| 65 | 'strings: different chars, <' => [-1, 'hello', 'hola'], |
||
| 66 | 'arrays: same' => [0, ['one' => 'world'], ['one' => 'world']], |
||
| 67 | 'arrays: different count, >' => [1, ['hola', 'mundo'], ['hello']], |
||
| 68 | 'arrays: different count, <' => [-1, ['hello'], ['hola', 'mundo']], |
||
| 69 | 'array > array (values)' => [1, ['hola', 'mundo'], ['hello', 'world']], |
||
| 70 | 'array < array (values)' => [-1, ['hello', 'world'], ['hola', 'mundo']], |
||
| 71 | 'array < array (keys)' => [-1, ['hola', 'mundo'], ['one' => 'hello', 'two' => 'world']], |
||
| 72 | 'array < stdClass' => [-1, [], new stdClass()], |
||
| 73 | 'stdClass > array' => [1, new stdClass(), []], |
||
| 74 | 'array > null' => [1, [], null], |
||
| 75 | 'null < array' => [-1, null, []], |
||
| 76 | 'array > int' => [1, [], 1], |
||
| 77 | 'int < array' => [-1, 1, []], |
||
| 78 | 'array > string' => [1, [], '1'], |
||
| 79 | 'string < array' => [-1, '1', []], |
||
| 80 | 'same reference ==' => [0, $obj, $obj], |
||
| 81 | 'empty classes ==' => [0, new A(), new A()], |
||
| 82 | 'different class' => [null, new A(), new stdClass()], |
||
| 83 | 'stdClass (empty) < stdClass' => [-1, new \stdClass(), $obj], |
||
| 84 | 'stdClass > stdClass (empty)' => [1, $obj, new \stdClass()], |
||
| 85 | 'stdClass > integer' => [1, $obj, 1234], |
||
| 86 | 'integer < stdClass' => [-1, 1234, $obj], |
||
| 87 | 'stdClass > string' => [1, $obj, '1234'], |
||
| 88 | 'string < stdClass' => [-1, '1234', $obj], |
||
| 89 | 'stdClass > null' => [1, $obj, null], |
||
| 90 | 'null < stdClass' => [-1, null, $obj], |
||
| 91 | 'float > null' => [1, 1.23, null], |
||
| 92 | 'null < float' => [-1, null, 1.23], |
||
| 93 | 'null < float (negative)' => [-1, null, -1.23], |
||
| 94 | 'float (negative) > null' => [1, -1.23, null], |
||
| 95 | 'float == integer' => [0, 1.00, 1], |
||
| 96 | 'float != integer' => [1, 1.0000001, 1], |
||
| 97 | 'floats near to zero' => [1, 0.00000000001, -0.00000000001], |
||
| 98 | 'float > integer' => [1, 1.23, 1], |
||
| 99 | 'integer < float' => [-1, 1, 1.23], |
||
| 100 | 'floats <' => [-1, 1.234, 1.2345], |
||
| 101 | 'bool cant integer' => [null, false, 19], |
||
| 102 | 'integer cant bool' => [null, 1, true], |
||
| 103 | 'boolean < boolean' => [-1, false, true], |
||
| 104 | 'boolean > boolean' => [1, true, false], |
||
| 105 | ]; |
||
| 106 | |||
| 107 | return $args; |
||
| 108 | } |
||
| 119 |