| Conditions | 6 |
| Paths | 10 |
| Total Lines | 250 |
| Code Lines | 224 |
| 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 |
||
| 48 | public function load(ObjectManager $manager) |
||
| 49 | { |
||
| 50 | $systemOut = <<<'EOT' |
||
| 51 | System out message : |
||
| 52 | - Out 1 |
||
| 53 | - Out 2 |
||
| 54 | EOT; |
||
| 55 | $systemErr = <<<'EOT' |
||
| 56 | System error message : |
||
| 57 | - Error 1, |
||
| 58 | - Error 2, |
||
| 59 | - Error 3. |
||
| 60 | EOT; |
||
| 61 | $failureMsg = <<<'EOT' |
||
| 62 | Type: Type of message |
||
| 63 | |||
| 64 | Message: Message |
||
| 65 | |||
| 66 | Details: Details of message ... |
||
| 67 | EOT; |
||
| 68 | $dataArray = array( |
||
| 69 | array( |
||
| 70 | 'count' => '12', |
||
| 71 | 'fullClassName' => array( |
||
| 72 | 'className2', |
||
| 73 | 'className2', |
||
| 74 | 'className1', |
||
| 75 | 'className1', |
||
| 76 | 'className1', |
||
| 77 | 'package1.className1', |
||
| 78 | 'io.ci-report.className3', |
||
| 79 | 'io.ci-report.className3', |
||
| 80 | 'io.ci-report.className3', |
||
| 81 | 'io.ci-report.className4', |
||
| 82 | 'io.ci-report.package.className4', |
||
| 83 | 'io.ci-report.package.className5', |
||
| 84 | ), |
||
| 85 | 'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 86 | 'duration' => 1, |
||
| 87 | 'systemOut' => $systemOut, |
||
| 88 | 'systemErr' => $systemErr, |
||
| 89 | 'failureMsg' => $failureMsg, |
||
| 90 | 'suite' => 'p1c1s1-suite', |
||
| 91 | ), |
||
| 92 | array( |
||
| 93 | 'count' => '13', |
||
| 94 | 'fullClassName' => array( |
||
| 95 | 'className2', |
||
| 96 | 'className2', |
||
| 97 | 'className1', |
||
| 98 | 'className1', |
||
| 99 | 'className1', |
||
| 100 | 'package1.className1', |
||
| 101 | 'io.ci-report.className3', |
||
| 102 | 'io.ci-report.className3', |
||
| 103 | 'io.ci-report.className3', |
||
| 104 | 'io.ci-report.className4', |
||
| 105 | 'io.ci-report.package.className4', |
||
| 106 | 'io.ci-report.package.className5', |
||
| 107 | 'io.ci-report.package.className6', |
||
| 108 | ), |
||
| 109 | 'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 110 | 'duration' => 1, |
||
| 111 | 'systemOut' => $systemOut, |
||
| 112 | 'systemErr' => $systemErr, |
||
| 113 | 'failureMsg' => $failureMsg, |
||
| 114 | 'suite' => 'p1c1s2-suite', |
||
| 115 | ), |
||
| 116 | array( |
||
| 117 | 'count' => '13', |
||
| 118 | 'fullClassName' => array( |
||
| 119 | 'className2', |
||
| 120 | 'className2', |
||
| 121 | 'className1', |
||
| 122 | 'className1', |
||
| 123 | 'className1', |
||
| 124 | 'package1.className1', |
||
| 125 | 'io.ci-report.className3', |
||
| 126 | 'io.ci-report.className3', |
||
| 127 | 'io.ci-report.className3', |
||
| 128 | 'io.ci-report.className4', |
||
| 129 | 'io.ci-report.package.className4', |
||
| 130 | 'io.ci-report.package.className5', |
||
| 131 | 'io.ci-report.package.className6', |
||
| 132 | ), |
||
| 133 | 'status' => array(Test::PASSED, Test::ERRORED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 134 | 'duration' => 1, |
||
| 135 | 'systemOut' => $systemOut, |
||
| 136 | 'systemErr' => $systemErr, |
||
| 137 | 'failureMsg' => $failureMsg, |
||
| 138 | 'suite' => 'p1c2s1-suite', |
||
| 139 | ), |
||
| 140 | array( |
||
| 141 | 'count' => '13', |
||
| 142 | 'fullClassName' => array( |
||
| 143 | 'className2', |
||
| 144 | 'className2', |
||
| 145 | 'className1', |
||
| 146 | 'className1', |
||
| 147 | 'className1', |
||
| 148 | 'package1.className1', |
||
| 149 | 'io.ci-report.className3', |
||
| 150 | 'io.ci-report.className3', |
||
| 151 | 'io.ci-report.className3', |
||
| 152 | 'io.ci-report.className4', |
||
| 153 | 'io.ci-report.package.className4', |
||
| 154 | 'io.ci-report.package.className5', |
||
| 155 | 'io.ci-report.package.className6', |
||
| 156 | ), |
||
| 157 | 'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 158 | 'duration' => 1, |
||
| 159 | 'systemOut' => $systemOut, |
||
| 160 | 'systemErr' => $systemErr, |
||
| 161 | 'failureMsg' => $failureMsg, |
||
| 162 | 'suite' => 'p1c2s2-suite', |
||
| 163 | ), |
||
| 164 | array( |
||
| 165 | 'count' => '13', |
||
| 166 | 'fullClassName' => array( |
||
| 167 | 'className2', |
||
| 168 | 'className2', |
||
| 169 | 'className1', |
||
| 170 | 'className1', |
||
| 171 | 'className1', |
||
| 172 | 'package1.className1', |
||
| 173 | 'io.ci-report.className3', |
||
| 174 | 'io.ci-report.className3', |
||
| 175 | 'io.ci-report.className3', |
||
| 176 | 'io.ci-report.className4', |
||
| 177 | 'io.ci-report.package.className4', |
||
| 178 | 'io.ci-report.package.className5', |
||
| 179 | 'io.ci-report.package.className6', |
||
| 180 | ), |
||
| 181 | 'status' => array(Test::PASSED, Test::FAILED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 182 | 'duration' => 1, |
||
| 183 | 'systemOut' => $systemOut, |
||
| 184 | 'systemErr' => $systemErr, |
||
| 185 | 'failureMsg' => $failureMsg, |
||
| 186 | 'suite' => 'p1c3s1-suite', |
||
| 187 | ), |
||
| 188 | array( |
||
| 189 | 'count' => '13', |
||
| 190 | 'fullClassName' => array( |
||
| 191 | 'className2', |
||
| 192 | 'className2', |
||
| 193 | 'className1', |
||
| 194 | 'className1', |
||
| 195 | 'className1', |
||
| 196 | 'package1.className1', |
||
| 197 | 'io.ci-report.className3', |
||
| 198 | 'io.ci-report.className3', |
||
| 199 | 'io.ci-report.className3', |
||
| 200 | 'io.ci-report.className4', |
||
| 201 | 'io.ci-report.package.className4', |
||
| 202 | 'io.ci-report.package.className5', |
||
| 203 | 'io.ci-report.package.className6', |
||
| 204 | ), |
||
| 205 | 'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 206 | 'duration' => 1, |
||
| 207 | 'systemOut' => $systemOut, |
||
| 208 | 'systemErr' => $systemErr, |
||
| 209 | 'failureMsg' => $failureMsg, |
||
| 210 | 'suite' => 'p1c3s2-suite', |
||
| 211 | ), |
||
| 212 | array( |
||
| 213 | 'count' => '13', |
||
| 214 | 'fullClassName' => array( |
||
| 215 | 'className2', |
||
| 216 | 'className2', |
||
| 217 | 'className1', |
||
| 218 | 'className1', |
||
| 219 | 'className1', |
||
| 220 | 'package1.className1', |
||
| 221 | 'io.ci-report.className3', |
||
| 222 | 'io.ci-report.className3', |
||
| 223 | 'io.ci-report.className3', |
||
| 224 | 'io.ci-report.className4', |
||
| 225 | 'io.ci-report.package.className4', |
||
| 226 | 'io.ci-report.package.className5', |
||
| 227 | 'io.ci-report.package.className6', |
||
| 228 | ), |
||
| 229 | 'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 230 | 'duration' => 1, |
||
| 231 | 'systemOut' => '', |
||
| 232 | 'systemErr' => '', |
||
| 233 | 'failureMsg' => '', |
||
| 234 | 'suite' => 'p1c4s1-suite', |
||
| 235 | ), |
||
| 236 | array( |
||
| 237 | 'count' => '13', |
||
| 238 | 'fullClassName' => array( |
||
| 239 | 'className2', |
||
| 240 | 'className2', |
||
| 241 | 'className1', |
||
| 242 | 'className1', |
||
| 243 | 'className1', |
||
| 244 | 'package1.className1', |
||
| 245 | 'io.ci-report.className3', |
||
| 246 | 'io.ci-report.className3', |
||
| 247 | 'io.ci-report.className3', |
||
| 248 | 'io.ci-report.className4', |
||
| 249 | 'io.ci-report.package.className4', |
||
| 250 | 'io.ci-report.package.className5', |
||
| 251 | 'io.ci-report.package.className6', |
||
| 252 | ), |
||
| 253 | 'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
||
| 254 | 'duration' => 1, |
||
| 255 | 'systemOut' => $systemOut, |
||
| 256 | 'systemErr' => $systemErr, |
||
| 257 | 'failureMsg' => $failureMsg, |
||
| 258 | 'suite' => 'p1c4s2-suite', |
||
| 259 | ), |
||
| 260 | $this->fillInTestArray(79, 21, 0, 0, 'p2c1s1-suite'), |
||
| 261 | $this->fillInTestArray(80, 20, 0, 0, 'p2c2s1-suite'), |
||
| 262 | $this->fillInTestArray(95, 4, 0, 1, 'p2c3s1-suite'), |
||
| 263 | $this->fillInTestArray(95, 5, 0, 0, 'p3c1s1-suite'), |
||
| 264 | $this->fillInTestArray(79, 21, 0, 0, 'p3c2s1-suite'), |
||
| 265 | $this->fillInTestArray(80, 20, 0, 0, 'p3c3s1-suite'), |
||
| 266 | $this->fillInTestArray(95, 0, 5, 0, 'p4c1s1-suite'), |
||
| 267 | $this->fillInTestArray(80, 0, 20, 0, 'p4c2s1-suite'), |
||
| 268 | $this->fillInTestArray(79, 0, 21, 0, 'p4c3s1-suite'), |
||
| 269 | $this->fillInTestArray(79, 0, 0, 21, 'p5c1s1-suite'), |
||
| 270 | $this->fillInTestArray(80, 0, 0, 20, 'p5c2s1-suite'), |
||
| 271 | $this->fillInTestArray(95, 0, 0, 5, 'p5c3s1-suite'), |
||
| 272 | $this->fillInTestArray(50, 0, 0, 0, 'p5c4s1-suite'), |
||
| 273 | ); |
||
| 274 | |||
| 275 | $objectList = array(); |
||
| 276 | foreach ($dataArray as $i => $data) { |
||
| 277 | for ($j = 0; $j < $data['count']; ++$j) { |
||
| 278 | $k = $i.$j; |
||
| 279 | $objectList[$k] = new Test($this->getReference($data['suite'])); |
||
| 280 | $objectList[$k]->setName('Test '.$j.' in '.$data['suite']); |
||
| 281 | $objectList[$k]->setFullClassName($data['fullClassName'][$j]); |
||
| 282 | $objectList[$k]->setStatus($data['status'][$j]); |
||
| 283 | $objectList[$k]->setDuration($data['duration'] + 0.1 * $j); |
||
| 284 | if ('' !== $data['systemOut']) { |
||
| 285 | $objectList[$k]->setSystemout($k.' : '.$data['systemOut']); |
||
| 286 | } |
||
| 287 | if ('' !== $data['systemErr']) { |
||
| 288 | $objectList[$k]->setSystemerr($k.' : '.$data['systemErr']); |
||
| 289 | } |
||
| 290 | if ('' !== $data['failureMsg']) { |
||
| 291 | $objectList[$k]->setFailuremsg($data['failureMsg']); |
||
| 292 | } |
||
| 293 | |||
| 294 | $manager->persist($objectList[$k]); |
||
| 295 | } |
||
| 296 | } |
||
| 297 | $manager->flush(); |
||
| 298 | } |
||
| 360 |