| Conditions | 1 |
| Paths | 1 |
| Total Lines | 148 |
| Code Lines | 88 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 3 | 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 |
||
| 81 | public function contactInfoDataProvider() |
||
| 82 | { |
||
| 83 | return [ |
||
| 84 | 'items count' => [null, $this->getEntity()], |
||
| 85 | 'without contact info' => [null, $this->getEntity(['itemsCount' => 1])], |
||
| 86 | 'email' => [ |
||
| 87 | $this->getEntity(['itemsCount' => 1, 'email' => '[email protected]']), |
||
| 88 | $this->getEntity(['itemsCount' => 1, 'email' => '[email protected]']), |
||
| 89 | |||
| 90 | ], |
||
| 91 | 'dont change status' => [ |
||
| 92 | $this->getEntity( |
||
| 93 | ['itemsCount' => 1, 'email' => '[email protected]', 'status' => new CartStatus('custom')] |
||
| 94 | ), |
||
| 95 | $this->getEntity( |
||
| 96 | ['itemsCount' => 1, 'email' => '[email protected]', 'status' => new CartStatus('custom')] |
||
| 97 | ), |
||
| 98 | $this->getEntity( |
||
| 99 | ['itemsCount' => 1, 'email' => '[email protected]', 'status' => new CartStatus('custom')] |
||
| 100 | ) |
||
| 101 | ], |
||
| 102 | 'change status' => [ |
||
| 103 | 'expected' => $this->getEntity( |
||
| 104 | ['itemsCount' => 1, 'email' => '[email protected]', 'status' => new CartStatus('expired')] |
||
| 105 | ), |
||
| 106 | 'entity' => $this->getEntity( |
||
| 107 | ['itemsCount' => 1, 'email' => '[email protected]', 'status' => new CartStatus('expired')] |
||
| 108 | ), |
||
| 109 | 'databaseEntity' => $this->getEntity( |
||
| 110 | ['itemsCount' => 1, 'email' => '[email protected]', 'status' => new CartStatus('open')] |
||
| 111 | ) |
||
| 112 | ], |
||
| 113 | 'update customer email' => [ |
||
| 114 | 'expected' => $this->getEntity( |
||
| 115 | [ |
||
| 116 | 'itemsCount' => 1, |
||
| 117 | 'email' => '[email protected]', |
||
| 118 | 'customer' => $this->getCustomer('[email protected]') |
||
| 119 | ] |
||
| 120 | ), |
||
| 121 | 'entity' => $this->getEntity( |
||
| 122 | [ |
||
| 123 | 'itemsCount' => 1, |
||
| 124 | 'email' => '[email protected]', |
||
| 125 | 'customer' => $this->getCustomer() |
||
| 126 | ] |
||
| 127 | ), |
||
| 128 | 'databaseEntity' => $this->getEntity( |
||
| 129 | [ |
||
| 130 | 'itemsCount' => 1, |
||
| 131 | 'email' => '[email protected]', |
||
| 132 | 'customer' => $this->getCustomer('[email protected]') |
||
| 133 | ] |
||
| 134 | ) |
||
| 135 | ], |
||
| 136 | 'add new cart item and remove old' => [ |
||
| 137 | 'expected' => $this->getEntity( |
||
| 138 | [ |
||
| 139 | 'itemsCount' => 1, |
||
| 140 | 'email' => '[email protected]', |
||
| 141 | 'cartItems' => new ArrayCollection([$this->getCartItem(1)]), |
||
| 142 | 'itemsQty' => 1, |
||
| 143 | ] |
||
| 144 | ), |
||
| 145 | 'entity' => $this->getEntity( |
||
| 146 | [ |
||
| 147 | 'itemsCount' => 1, |
||
| 148 | 'email' => '[email protected]', |
||
| 149 | 'cartItems' => new ArrayCollection([$this->getCartItem(1)]), |
||
| 150 | 'itemsQty' => 1, |
||
| 151 | ] |
||
| 152 | ), |
||
| 153 | 'databaseEntity' => $this->getEntity( |
||
| 154 | [ |
||
| 155 | 'itemsCount' => 1, |
||
| 156 | 'email' => '[email protected]', |
||
| 157 | 'cartItems' => new ArrayCollection([$this->getCartItem(2)]), |
||
| 158 | 'itemsQty' => 1, |
||
| 159 | ] |
||
| 160 | ) |
||
| 161 | ], |
||
| 162 | 'add new cart item and keep old one' => [ |
||
| 163 | 'expected' => $this->getEntity( |
||
| 164 | [ |
||
| 165 | 'itemsCount' => 1, |
||
| 166 | 'email' => '[email protected]', |
||
| 167 | 'cartItems' => new ArrayCollection([$this->getCartItem(1), $this->getCartItem(2)]), |
||
| 168 | 'itemsQty' => 2, |
||
| 169 | ] |
||
| 170 | ), |
||
| 171 | 'entity' => $this->getEntity( |
||
| 172 | [ |
||
| 173 | 'itemsCount' => 1, |
||
| 174 | 'email' => '[email protected]', |
||
| 175 | 'cartItems' => new ArrayCollection([$this->getCartItem(1), $this->getCartItem(2)]), |
||
| 176 | 'itemsQty' => 2, |
||
| 177 | ] |
||
| 178 | ), |
||
| 179 | 'databaseEntity' => $this->getEntity( |
||
| 180 | [ |
||
| 181 | 'itemsCount' => 1, |
||
| 182 | 'email' => '[email protected]', |
||
| 183 | 'cartItems' => new ArrayCollection([$this->getCartItem(2)]), |
||
| 184 | 'itemsQty' => 1, |
||
| 185 | ] |
||
| 186 | ) |
||
| 187 | ], |
||
| 188 | 'update existing address' => [ |
||
| 189 | 'expected' => $this->getEntity( |
||
| 190 | [ |
||
| 191 | 'itemsCount' => 1, |
||
| 192 | 'email' => '[email protected]', |
||
| 193 | 'shippingAddress' => $this->getAddress('US') |
||
| 194 | ] |
||
| 195 | ), |
||
| 196 | 'entity' => $this->getEntity( |
||
| 197 | [ |
||
| 198 | 'itemsCount' => 1, |
||
| 199 | 'email' => '[email protected]', |
||
| 200 | 'shippingAddress' => $this->getAddress('US') |
||
| 201 | ] |
||
| 202 | ), |
||
| 203 | 'databaseEntity' => $this->getEntity( |
||
| 204 | [ |
||
| 205 | 'itemsCount' => 1, |
||
| 206 | 'email' => '[email protected]', |
||
| 207 | 'shippingAddress' => $this->getAddress('US') |
||
| 208 | ] |
||
| 209 | ) |
||
| 210 | ], |
||
| 211 | 'drop without country' => [ |
||
| 212 | 'expected' => $this->getEntity( |
||
| 213 | [ |
||
| 214 | 'itemsCount' => 1, |
||
| 215 | 'email' => '[email protected]', |
||
| 216 | 'billingAddress' => null |
||
| 217 | ] |
||
| 218 | ), |
||
| 219 | 'entity' => $this->getEntity( |
||
| 220 | [ |
||
| 221 | 'itemsCount' => 1, |
||
| 222 | 'email' => '[email protected]', |
||
| 223 | 'billingAddress' => $this->getAddress() |
||
| 224 | ] |
||
| 225 | ) |
||
| 226 | ] |
||
| 227 | ]; |
||
| 228 | } |
||
| 229 | |||
| 375 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: