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