| Conditions | 2 |
| Paths | 2 |
| Total Lines | 73 |
| Code Lines | 46 |
| 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 |
||
| 136 | public function testPositionDependency(int $pos, bool $jqAlreadyRegistered): void |
||
| 137 | { |
||
| 138 | $this->assetManager->setBundles([ |
||
| 139 | PositionAsset::class => [ |
||
| 140 | 'jsOptions' => [ |
||
| 141 | 'position' => $pos, |
||
| 142 | ], |
||
| 143 | ] |
||
| 144 | ]); |
||
| 145 | |||
| 146 | $this->assertEmpty($this->assetManager->getAssetBundles()); |
||
| 147 | |||
| 148 | if ($jqAlreadyRegistered) { |
||
| 149 | $this->assetManager->register([JqueryAsset::class, PositionAsset::class]); |
||
| 150 | } else { |
||
| 151 | $this->assetManager->register([PositionAsset::class]); |
||
| 152 | } |
||
| 153 | |||
| 154 | $this->assertCount(3, $this->assetManager->getAssetBundles()); |
||
| 155 | $this->assertArrayHasKey(PositionAsset::class, $this->assetManager->getAssetBundles()); |
||
| 156 | $this->assertArrayHasKey(JqueryAsset::class, $this->assetManager->getAssetBundles()); |
||
| 157 | $this->assertArrayHasKey(Level3Asset::class, $this->assetManager->getAssetBundles()); |
||
| 158 | |||
| 159 | $this->assertInstanceOf( |
||
| 160 | AssetBundle::class, |
||
| 161 | $this->assetManager->getAssetBundles()[PositionAsset::class] |
||
| 162 | ); |
||
| 163 | $this->assertInstanceOf( |
||
| 164 | AssetBundle::class, |
||
| 165 | $this->assetManager->getAssetBundles()[JqueryAsset::class] |
||
| 166 | ); |
||
| 167 | $this->assertInstanceOf( |
||
| 168 | AssetBundle::class, |
||
| 169 | $this->assetManager->getAssetBundles()[Level3Asset::class] |
||
| 170 | ); |
||
| 171 | |||
| 172 | $this->assertArrayHasKey( |
||
| 173 | 'position', |
||
| 174 | $this->assetManager->getAssetBundles()[PositionAsset::class]->jsOptions |
||
| 175 | ); |
||
| 176 | $this->assertEquals( |
||
| 177 | $pos, |
||
| 178 | $this->assetManager->getAssetBundles()[PositionAsset::class]->jsOptions['position'] |
||
| 179 | ); |
||
| 180 | $this->assertArrayHasKey( |
||
| 181 | 'position', |
||
| 182 | $this->assetManager->getAssetBundles()[JqueryAsset::class]->jsOptions |
||
| 183 | ); |
||
| 184 | |||
| 185 | $this->assertEquals( |
||
| 186 | $pos, |
||
| 187 | $this->assetManager->getAssetBundles()[JqueryAsset::class]->jsOptions['position'] |
||
| 188 | ); |
||
| 189 | $this->assertArrayHasKey( |
||
| 190 | 'position', |
||
| 191 | $this->assetManager->getAssetBundles()[Level3Asset::class]->jsOptions |
||
| 192 | ); |
||
| 193 | $this->assertEquals( |
||
| 194 | $pos, |
||
| 195 | $this->assetManager->getAssetBundles()[Level3Asset::class]->jsOptions['position'] |
||
| 196 | ); |
||
| 197 | |||
| 198 | $this->assertEquals( |
||
| 199 | [ |
||
| 200 | 'position' => $pos |
||
| 201 | ], |
||
| 202 | $this->assetManager->getJsFiles()['/js/jquery.js']['attributes'] |
||
| 203 | ); |
||
| 204 | $this->assertEquals( |
||
| 205 | [ |
||
| 206 | 'position' => $pos |
||
| 207 | ], |
||
| 208 | $this->assetManager->getJsFiles()['/files/jsFile.js']['attributes'] |
||
| 209 | ); |
||
| 268 |