| Conditions | 1 |
| Paths | 1 |
| Total Lines | 66 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 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 |
||
| 59 | public function getTestGenerateData() |
||
| 60 | { |
||
| 61 | $data = []; |
||
| 62 | $template = 'ONGRSettingsBundle:Utils:hidden.html.twig'; |
||
| 63 | |||
| 64 | // Case 0: dont check request. |
||
| 65 | $data0 = [ |
||
| 66 | 'test1' => 1, |
||
| 67 | 'nested2' => [5, 4], |
||
| 68 | ]; |
||
| 69 | $env0 = $this->getMock('stdClass', ['render']); |
||
| 70 | $env0 |
||
| 71 | ->expects($this->once()) |
||
| 72 | ->method('render') |
||
| 73 | ->with( |
||
| 74 | $template, |
||
| 75 | [ |
||
| 76 | 'data' => [ |
||
| 77 | [ |
||
| 78 | 'value' => 1, |
||
| 79 | 'name' => 'test1', |
||
| 80 | ], |
||
| 81 | [ |
||
| 82 | 'value' => 5, |
||
| 83 | 'name' => 'nested2[]', |
||
| 84 | ], |
||
| 85 | [ |
||
| 86 | 'value' => 4, |
||
| 87 | 'name' => 'nested2[]', |
||
| 88 | ], |
||
| 89 | ], |
||
| 90 | ] |
||
| 91 | ); |
||
| 92 | $container0 = $this->getContainer(); |
||
| 93 | |||
| 94 | $data[] = [$data0, false, $env0, $container0]; |
||
| 95 | |||
| 96 | // Case 1: check request. |
||
| 97 | $data1 = [ |
||
| 98 | 'test1' => 1, |
||
| 99 | 'test12' => 12, |
||
| 100 | 'nested2' => [5, 4], |
||
| 101 | ]; |
||
| 102 | $env1 = $this->getMock('stdClass', ['render']); |
||
| 103 | $env1 |
||
| 104 | ->expects($this->once()) |
||
| 105 | ->method('render') |
||
| 106 | ->with( |
||
| 107 | $template, |
||
| 108 | [ |
||
| 109 | 'data' => [], |
||
| 110 | ] |
||
| 111 | ); |
||
| 112 | $container1 = $this->getContainer( |
||
| 113 | new Request( |
||
| 114 | [ |
||
| 115 | 'test12' => 'smth', |
||
| 116 | 'nested2' => 'smth', |
||
| 117 | ] |
||
| 118 | ) |
||
| 119 | ); |
||
| 120 | |||
| 121 | $data[] = [$data1, true, $env1, $container1]; |
||
| 122 | |||
| 123 | return $data; |
||
| 124 | } |
||
| 125 | |||
| 142 |