Conditions | 1 |
Paths | 1 |
Total Lines | 57 |
Code Lines | 45 |
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 |
||
64 | public function testCombineAcceptsTraversable() |
||
65 | { |
||
66 | $stub = $this->getIteratorForArray($this->fixtures['emails']); |
||
67 | $coll = Factory::create($this->fixtures['names']); |
||
68 | $this->assertSame( |
||
69 | [ |
||
70 | 'Chelsea', |
||
71 | 'Adella', |
||
72 | 'Monte', |
||
73 | 'Maye', |
||
74 | 'Lottie', |
||
75 | 'Don', |
||
76 | 'Dayton', |
||
77 | 'Kirk', |
||
78 | 'Troy', |
||
79 | 'Nakia', |
||
80 | ], |
||
81 | $coll->toArray() |
||
82 | ); |
||
83 | $this->assertSame( |
||
84 | [ |
||
85 | '[email protected]', |
||
86 | '[email protected]', |
||
87 | '[email protected]', |
||
88 | '[email protected]', |
||
89 | '[email protected]', |
||
90 | '[email protected]', |
||
91 | '[email protected]', |
||
92 | '[email protected]', |
||
93 | '[email protected]', |
||
94 | '[email protected]', |
||
95 | ], |
||
96 | Factory::getArrayForItems($stub) |
||
97 | ); |
||
98 | $orig = $coll->toArray(); |
||
99 | $return = $coll->combine($stub); |
||
100 | $this->assertEquals( |
||
101 | [ |
||
102 | 'Chelsea' => '[email protected]', |
||
103 | 'Adella' => '[email protected]', |
||
104 | 'Monte' => '[email protected]', |
||
105 | 'Maye' => '[email protected]', |
||
106 | 'Lottie' => '[email protected]', |
||
107 | 'Don' => '[email protected]', |
||
108 | 'Dayton' => '[email protected]', |
||
109 | 'Kirk' => '[email protected]', |
||
110 | 'Troy' => '[email protected]', |
||
111 | 'Nakia' => '[email protected]', |
||
112 | ], |
||
113 | $return->toArray() |
||
114 | ); |
||
115 | $this->assertSame( |
||
116 | $orig, |
||
117 | $coll->toArray(), |
||
118 | 'Ensure that Collection::combine() has not changed the original collection.' |
||
119 | ); |
||
120 | } |
||
121 | |||
142 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: