| Conditions | 3 |
| Paths | 4 |
| Total Lines | 54 |
| Code Lines | 37 |
| 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 |
||
| 15 | public function provider() |
||
| 16 | { |
||
| 17 | $header = [ |
||
| 18 | 'recType' => Record\Header::NORMAL_REC_TYPE, |
||
| 19 | 'prodName' => '@(#) SPSS DATA FILE', |
||
| 20 | 'layoutCode' => 2, |
||
| 21 | 'nominalCaseSize' => 0, |
||
| 22 | 'casesCount' => 1, //mt_rand(10, 100), |
||
| 23 | 'compression' => 1, |
||
| 24 | 'weightIndex' => 0, |
||
| 25 | 'bias' => 100, |
||
| 26 | 'creationDate' => date('d M y'), |
||
| 27 | 'creationTime' => date('H:i:s'), |
||
| 28 | 'fileLabel' => 'test read/write', |
||
| 29 | ]; |
||
| 30 | |||
| 31 | $documents = [ |
||
| 32 | $this->generateRandomString(mt_rand(5, Record\Document::LENGTH)), |
||
| 33 | $this->generateRandomString(mt_rand(5, Record\Document::LENGTH)), |
||
| 34 | ]; |
||
| 35 | |||
| 36 | $variables = []; |
||
| 37 | |||
| 38 | // Generate random variables |
||
| 39 | |||
| 40 | $count = 1; //mt_rand(1, 20); |
||
| 41 | for ($i = 0; $i < $count; $i++) { |
||
| 42 | $var = $this->generateVariable([ |
||
| 43 | 'id' => $this->generateRandomString(mt_rand(2, 100)), |
||
| 44 | 'casesCount' => $header['casesCount'], |
||
| 45 | ] |
||
| 46 | ); |
||
| 47 | $header['nominalCaseSize'] += $var->getOcts(); |
||
| 48 | $variables[] = $var; |
||
| 49 | } |
||
| 50 | |||
| 51 | |||
| 52 | yield [[ |
||
|
|
|||
| 53 | 'header' => $header, |
||
| 54 | 'variables' => $variables, |
||
| 55 | 'documents' => $documents |
||
| 56 | ]]; |
||
| 57 | |||
| 58 | $header['casesCount'] = 5; |
||
| 59 | for($i = 0; $i < 1000; $i++) { |
||
| 60 | $variable = $this->generateVariable([ |
||
| 61 | 'id' => $this->generateRandomString(mt_rand(2, 100)), |
||
| 62 | 'casesCount' => $header['casesCount'] |
||
| 63 | ]); |
||
| 64 | $header['nominalCaseSize'] = $variable->getOcts(); |
||
| 65 | yield [[ |
||
| 66 | 'header' => $header, |
||
| 67 | 'variables' => [$variable], |
||
| 68 | 'documents' => $documents |
||
| 69 | ]]; |
||
| 126 |