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