| Conditions | 3 |
| Paths | 3 |
| Total Lines | 324 |
| Code Lines | 294 |
| 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 |
||
| 49 | public function load(ObjectManager $manager) |
||
| 50 | { |
||
| 51 | $ref1Date = new DateTime(); |
||
| 52 | $ref1Date->setDate(2017, 7, 1)->setTime(12, 30, 1); |
||
| 53 | $ref2Date = new DateTime(); |
||
| 54 | $ref2Date->setDate(2017, 7, 2)->setTime(12, 30, 1); |
||
| 55 | $ref3Date = new DateTime(); |
||
| 56 | $ref3Date->setDate(2017, 7, 3)->setTime(12, 30, 1); |
||
| 57 | $ref4Date = new DateTime(); |
||
| 58 | $ref4Date->setDate(2017, 7, 4)->setTime(12, 30, 1); |
||
| 59 | |||
| 60 | $dataArray = array( |
||
| 61 | array( |
||
| 62 | 'name' => 'Name of suite 1 for campaign 1 Project 1', |
||
| 63 | 'passed' => 12, |
||
| 64 | 'failed' => 0, |
||
| 65 | 'errored' => 0, |
||
| 66 | 'skipped' => 0, |
||
| 67 | 'disabled' => 0, |
||
| 68 | 'duration' => 1.1, |
||
| 69 | 'datetime' => $ref1Date, |
||
| 70 | 'project' => 'projectone-project', |
||
| 71 | 'campaign' => 'p1c1-campaign', |
||
| 72 | 'suiteRef' => 'p1c1s1', |
||
| 73 | 'documentuid' => 'd8329fc1cc938780ffdd9f94e0d364e0ea74f579', |
||
| 74 | ), |
||
| 75 | array( |
||
| 76 | 'name' => 'Name of suite 2 for campaign 1 Project 1', |
||
| 77 | 'passed' => 13, |
||
| 78 | 'failed' => 0, |
||
| 79 | 'errored' => 0, |
||
| 80 | 'skipped' => 0, |
||
| 81 | 'disabled' => 0, |
||
| 82 | 'duration' => 1.1, |
||
| 83 | 'datetime' => $ref1Date, |
||
| 84 | 'project' => 'projectone-project', |
||
| 85 | 'campaign' => 'p1c1-campaign', |
||
| 86 | 'suiteRef' => 'p1c1s2', |
||
| 87 | ), |
||
| 88 | array( |
||
| 89 | 'name' => 'Name of suite 1 for campaign 2 Project 1', |
||
| 90 | 'passed' => 12, |
||
| 91 | 'failed' => 0, |
||
| 92 | 'errored' => 1, |
||
| 93 | 'skipped' => 0, |
||
| 94 | 'disabled' => 0, |
||
| 95 | 'duration' => 1.1, |
||
| 96 | 'datetime' => $ref2Date, |
||
| 97 | 'project' => 'projectone-project', |
||
| 98 | 'campaign' => 'p1c2-campaign', |
||
| 99 | 'suiteRef' => 'p1c2s1', |
||
| 100 | ), |
||
| 101 | array( |
||
| 102 | 'name' => 'Name of suite 2 for campaign 2 Project 1', |
||
| 103 | 'passed' => 13, |
||
| 104 | 'failed' => 0, |
||
| 105 | 'errored' => 0, |
||
| 106 | 'skipped' => 0, |
||
| 107 | 'disabled' => 0, |
||
| 108 | 'duration' => 1.1, |
||
| 109 | 'datetime' => $ref2Date, |
||
| 110 | 'project' => 'projectone-project', |
||
| 111 | 'campaign' => 'p1c2-campaign', |
||
| 112 | 'suiteRef' => 'p1c2s2', |
||
| 113 | ), |
||
| 114 | array( |
||
| 115 | 'name' => 'Name of suite 1 for campaign 3 Project 1', |
||
| 116 | 'passed' => 12, |
||
| 117 | 'failed' => 1, |
||
| 118 | 'errored' => 0, |
||
| 119 | 'skipped' => 0, |
||
| 120 | 'disabled' => 0, |
||
| 121 | 'duration' => 1.1, |
||
| 122 | 'datetime' => $ref3Date, |
||
| 123 | 'project' => 'projectone-project', |
||
| 124 | 'campaign' => 'p1c3-campaign', |
||
| 125 | 'suiteRef' => 'p1c3s1', |
||
| 126 | ), |
||
| 127 | array( |
||
| 128 | 'name' => 'Name of suite 2 for campaign 3 Project 1', |
||
| 129 | 'passed' => 13, |
||
| 130 | 'failed' => 0, |
||
| 131 | 'errored' => 0, |
||
| 132 | 'skipped' => 0, |
||
| 133 | 'disabled' => 0, |
||
| 134 | 'duration' => 1.1, |
||
| 135 | 'datetime' => $ref3Date, |
||
| 136 | 'project' => 'projectone-project', |
||
| 137 | 'campaign' => 'p1c3-campaign', |
||
| 138 | 'suiteRef' => 'p1c3s2', |
||
| 139 | ), |
||
| 140 | array( |
||
| 141 | 'name' => 'Name of suite 1 for campaign 4 Project 1', |
||
| 142 | 'passed' => 13, |
||
| 143 | 'failed' => 0, |
||
| 144 | 'errored' => 0, |
||
| 145 | 'skipped' => 0, |
||
| 146 | 'disabled' => 0, |
||
| 147 | 'duration' => 1.1, |
||
| 148 | 'datetime' => $ref4Date, |
||
| 149 | 'project' => 'projectone-project', |
||
| 150 | 'campaign' => 'p1c4-campaign', |
||
| 151 | 'suiteRef' => 'p1c4s1', |
||
| 152 | 'documentuid' => '1f7a7a472abf3dd9643fd615f6da379c4acb3e3a', |
||
| 153 | ), |
||
| 154 | array( |
||
| 155 | 'name' => 'Name of suite 2 for campaign 4 Project 1', |
||
| 156 | 'passed' => 13, |
||
| 157 | 'failed' => 0, |
||
| 158 | 'errored' => 0, |
||
| 159 | 'skipped' => 0, |
||
| 160 | 'disabled' => 0, |
||
| 161 | 'duration' => 1.1, |
||
| 162 | 'datetime' => $ref4Date, |
||
| 163 | 'project' => 'projectone-project', |
||
| 164 | 'campaign' => 'p1c4-campaign', |
||
| 165 | 'suiteRef' => 'p1c4s2', |
||
| 166 | ), |
||
| 167 | array( |
||
| 168 | 'name' => 'Name of suite 1 for campaign 1 Project 2', |
||
| 169 | 'passed' => 79, |
||
| 170 | 'failed' => 21, |
||
| 171 | 'errored' => 0, |
||
| 172 | 'skipped' => 0, |
||
| 173 | 'disabled' => 0, |
||
| 174 | 'duration' => 1.1, |
||
| 175 | 'datetime' => $ref1Date, |
||
| 176 | 'project' => 'projecttwo-project', |
||
| 177 | 'campaign' => 'p2c1-campaign', |
||
| 178 | 'suiteRef' => 'p2c1s1', |
||
| 179 | ), |
||
| 180 | array( |
||
| 181 | 'name' => 'Name of suite 1 for campaign 2 Project 2', |
||
| 182 | 'passed' => 80, |
||
| 183 | 'failed' => 20, |
||
| 184 | 'errored' => 0, |
||
| 185 | 'skipped' => 0, |
||
| 186 | 'disabled' => 0, |
||
| 187 | 'duration' => 1.1, |
||
| 188 | 'datetime' => $ref2Date, |
||
| 189 | 'project' => 'projecttwo-project', |
||
| 190 | 'campaign' => 'p2c2-campaign', |
||
| 191 | 'suiteRef' => 'p2c2s1', |
||
| 192 | ), |
||
| 193 | array( |
||
| 194 | 'name' => 'Name of suite 1 for campaign 3 Project 2', |
||
| 195 | 'passed' => 95, |
||
| 196 | 'failed' => 4, |
||
| 197 | 'errored' => 0, |
||
| 198 | 'skipped' => 1, |
||
| 199 | 'disabled' => 0, |
||
| 200 | 'duration' => 1.1, |
||
| 201 | 'datetime' => $ref3Date, |
||
| 202 | 'project' => 'projecttwo-project', |
||
| 203 | 'campaign' => 'p2c3-campaign', |
||
| 204 | 'suiteRef' => 'p2c3s1', |
||
| 205 | ), |
||
| 206 | array( |
||
| 207 | 'name' => 'Name of suite 1 for campaign 1 Project 3', |
||
| 208 | 'passed' => 95, |
||
| 209 | 'failed' => 5, |
||
| 210 | 'errored' => 0, |
||
| 211 | 'skipped' => 0, |
||
| 212 | 'disabled' => 0, |
||
| 213 | 'duration' => 1.1, |
||
| 214 | 'datetime' => $ref1Date, |
||
| 215 | 'project' => 'projectthree-project', |
||
| 216 | 'campaign' => 'p3c1-campaign', |
||
| 217 | 'suiteRef' => 'p3c1s1', |
||
| 218 | ), |
||
| 219 | array( |
||
| 220 | 'name' => 'Name of suite 1 for campaign 2 Project 3', |
||
| 221 | 'passed' => 79, |
||
| 222 | 'failed' => 21, |
||
| 223 | 'errored' => 0, |
||
| 224 | 'skipped' => 0, |
||
| 225 | 'disabled' => 0, |
||
| 226 | 'duration' => 1.1, |
||
| 227 | 'datetime' => $ref2Date, |
||
| 228 | 'project' => 'projectthree-project', |
||
| 229 | 'campaign' => 'p3c2-campaign', |
||
| 230 | 'suiteRef' => 'p3c2s1', |
||
| 231 | ), |
||
| 232 | array( |
||
| 233 | 'name' => 'Name of suite 1 for campaign 3 Project 3', |
||
| 234 | 'passed' => 80, |
||
| 235 | 'failed' => 20, |
||
| 236 | 'errored' => 0, |
||
| 237 | 'skipped' => 0, |
||
| 238 | 'disabled' => 0, |
||
| 239 | 'duration' => 1.1, |
||
| 240 | 'datetime' => $ref3Date, |
||
| 241 | 'project' => 'projectthree-project', |
||
| 242 | 'campaign' => 'p3c3-campaign', |
||
| 243 | 'suiteRef' => 'p3c3s1', |
||
| 244 | ), |
||
| 245 | array( |
||
| 246 | 'name' => 'Name of suite 1 for campaign 1 Project 4', |
||
| 247 | 'passed' => 95, |
||
| 248 | 'failed' => 0, |
||
| 249 | 'errored' => 5, |
||
| 250 | 'skipped' => 0, |
||
| 251 | 'disabled' => 0, |
||
| 252 | 'duration' => 1.1, |
||
| 253 | 'datetime' => $ref1Date, |
||
| 254 | 'project' => 'projectfour-project', |
||
| 255 | 'campaign' => 'p4c1-campaign', |
||
| 256 | 'suiteRef' => 'p4c1s1', |
||
| 257 | ), |
||
| 258 | array( |
||
| 259 | 'name' => 'Name of suite 1 for campaign 2 Project 4', |
||
| 260 | 'passed' => 80, |
||
| 261 | 'failed' => 0, |
||
| 262 | 'errored' => 20, |
||
| 263 | 'skipped' => 0, |
||
| 264 | 'disabled' => 0, |
||
| 265 | 'duration' => 1.1, |
||
| 266 | 'datetime' => $ref2Date, |
||
| 267 | 'project' => 'projectfour-project', |
||
| 268 | 'campaign' => 'p4c2-campaign', |
||
| 269 | 'suiteRef' => 'p4c2s1', |
||
| 270 | ), |
||
| 271 | array( |
||
| 272 | 'name' => 'Name of suite 1 for campaign 3 Project 4', |
||
| 273 | 'passed' => 79, |
||
| 274 | 'failed' => 0, |
||
| 275 | 'errored' => 21, |
||
| 276 | 'skipped' => 0, |
||
| 277 | 'disabled' => 0, |
||
| 278 | 'duration' => 1.1, |
||
| 279 | 'datetime' => $ref3Date, |
||
| 280 | 'project' => 'projectfour-project', |
||
| 281 | 'campaign' => 'p4c3-campaign', |
||
| 282 | 'suiteRef' => 'p4c3s1', |
||
| 283 | ), |
||
| 284 | array( |
||
| 285 | 'name' => 'Name of suite 1 for campaign 1 Project 5', |
||
| 286 | 'passed' => 79, |
||
| 287 | 'failed' => 0, |
||
| 288 | 'errored' => 0, |
||
| 289 | 'skipped' => 21, |
||
| 290 | 'disabled' => 0, |
||
| 291 | 'duration' => 1.1, |
||
| 292 | 'datetime' => $ref1Date, |
||
| 293 | 'project' => 'projectfive-project', |
||
| 294 | 'campaign' => 'p5c1-campaign', |
||
| 295 | 'suiteRef' => 'p5c1s1', |
||
| 296 | ), |
||
| 297 | array( |
||
| 298 | 'name' => 'Name of suite 1 for campaign 2 Project 5', |
||
| 299 | 'passed' => 80, |
||
| 300 | 'failed' => 0, |
||
| 301 | 'errored' => 0, |
||
| 302 | 'skipped' => 20, |
||
| 303 | 'disabled' => 0, |
||
| 304 | 'duration' => 1.1, |
||
| 305 | 'datetime' => $ref2Date, |
||
| 306 | 'project' => 'projectfive-project', |
||
| 307 | 'campaign' => 'p5c2-campaign', |
||
| 308 | 'suiteRef' => 'p5c2s1', |
||
| 309 | ), |
||
| 310 | array( |
||
| 311 | 'name' => 'Name of suite 1 for campaign 3 Project 5', |
||
| 312 | 'passed' => 95, |
||
| 313 | 'failed' => 0, |
||
| 314 | 'errored' => 0, |
||
| 315 | 'skipped' => 5, |
||
| 316 | 'disabled' => 0, |
||
| 317 | 'duration' => 1.1, |
||
| 318 | 'datetime' => $ref3Date, |
||
| 319 | 'project' => 'projectfive-project', |
||
| 320 | 'campaign' => 'p5c3-campaign', |
||
| 321 | 'suiteRef' => 'p5c3s1', |
||
| 322 | ), |
||
| 323 | array( |
||
| 324 | 'name' => 'Name of suite 1 for campaign 4 Project 5', |
||
| 325 | 'passed' => 50, |
||
| 326 | 'failed' => 0, |
||
| 327 | 'errored' => 0, |
||
| 328 | 'skipped' => 0, |
||
| 329 | 'disabled' => 50, |
||
| 330 | 'duration' => 1.1, |
||
| 331 | 'datetime' => $ref4Date, |
||
| 332 | 'project' => 'projectfive-project', |
||
| 333 | 'campaign' => 'p5c4-campaign', |
||
| 334 | 'suiteRef' => 'p5c4s1', |
||
| 335 | ), |
||
| 336 | array( |
||
| 337 | 'name' => 'Name of suite 1 for campaign 1 Project 8', |
||
| 338 | 'passed' => 0, |
||
| 339 | 'failed' => 0, |
||
| 340 | 'errored' => 0, |
||
| 341 | 'skipped' => 0, |
||
| 342 | 'disabled' => 0, |
||
| 343 | 'duration' => 0, |
||
| 344 | 'datetime' => $ref4Date, |
||
| 345 | 'project' => 'projecteight-project', |
||
| 346 | 'campaign' => 'p8c1-campaign', |
||
| 347 | 'suiteRef' => 'p8c1s1', |
||
| 348 | ), |
||
| 349 | ); |
||
| 350 | $objectList = array(); |
||
| 351 | foreach ($dataArray as $i => $data) { |
||
| 352 | $objectList[$i] = new Suite( |
||
| 353 | $this->getReference($data['project']), |
||
| 354 | $this->getReference($data['campaign']) |
||
| 355 | ); |
||
| 356 | $objectList[$i]->setName($data['name']); |
||
| 357 | $objectList[$i]->setPassed($data['passed']); |
||
| 358 | $objectList[$i]->setFailed($data['failed']); |
||
| 359 | $objectList[$i]->setErrored($data['errored']); |
||
| 360 | $objectList[$i]->setSkipped($data['skipped']); |
||
| 361 | $objectList[$i]->setDisabled($data['disabled']); |
||
| 362 | $objectList[$i]->setDuration($data['duration']); |
||
| 363 | $objectList[$i]->setDateTime($data['datetime']); |
||
| 364 | if (isset($data['documentuid'])) { |
||
| 365 | $objectList[$i]->setDocumentUid($data['documentuid']); |
||
| 366 | } |
||
| 367 | |||
| 368 | $manager->persist($objectList[$i]); |
||
| 369 | $ref = $data['suiteRef'].'-suite'; |
||
| 370 | $this->addReference($ref, $objectList[$i]); |
||
| 371 | } |
||
| 372 | $manager->flush(); |
||
| 373 | } |
||
| 385 |