| Conditions | 2 |
| Paths | 2 |
| Total Lines | 73 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 37 | public function testPositionDependency(int $pos, bool $jqAlreadyRegistered): void |
||
| 38 | { |
||
| 39 | $this->assetManager->setBundles([ |
||
| 40 | PositionAsset::class => [ |
||
| 41 | 'jsOptions' => [ |
||
| 42 | 'position' => $pos, |
||
| 43 | ], |
||
| 44 | ] |
||
| 45 | ]); |
||
| 46 | |||
| 47 | $this->assertEmpty($this->assetManager->getAssetBundles()); |
||
| 48 | |||
| 49 | if ($jqAlreadyRegistered) { |
||
| 50 | $this->assetManager->register([JqueryAsset::class, PositionAsset::class]); |
||
| 51 | } else { |
||
| 52 | $this->assetManager->register([PositionAsset::class]); |
||
| 53 | } |
||
| 54 | |||
| 55 | $this->assertCount(3, $this->assetManager->getAssetBundles()); |
||
| 56 | $this->assertArrayHasKey(PositionAsset::class, $this->assetManager->getAssetBundles()); |
||
| 57 | $this->assertArrayHasKey(JqueryAsset::class, $this->assetManager->getAssetBundles()); |
||
| 58 | $this->assertArrayHasKey(Level3Asset::class, $this->assetManager->getAssetBundles()); |
||
| 59 | |||
| 60 | $this->assertInstanceOf( |
||
| 61 | AssetBundle::class, |
||
| 62 | $this->assetManager->getAssetBundles()[PositionAsset::class] |
||
| 63 | ); |
||
| 64 | $this->assertInstanceOf( |
||
| 65 | AssetBundle::class, |
||
| 66 | $this->assetManager->getAssetBundles()[JqueryAsset::class] |
||
| 67 | ); |
||
| 68 | $this->assertInstanceOf( |
||
| 69 | AssetBundle::class, |
||
| 70 | $this->assetManager->getAssetBundles()[Level3Asset::class] |
||
| 71 | ); |
||
| 72 | |||
| 73 | $this->assertArrayHasKey( |
||
| 74 | 'position', |
||
| 75 | $this->assetManager->getAssetBundles()[PositionAsset::class]->jsOptions |
||
| 76 | ); |
||
| 77 | $this->assertEquals( |
||
| 78 | $pos, |
||
| 79 | $this->assetManager->getAssetBundles()[PositionAsset::class]->jsOptions['position'] |
||
| 80 | ); |
||
| 81 | $this->assertArrayHasKey( |
||
| 82 | 'position', |
||
| 83 | $this->assetManager->getAssetBundles()[JqueryAsset::class]->jsOptions |
||
| 84 | ); |
||
| 85 | |||
| 86 | $this->assertEquals( |
||
| 87 | $pos, |
||
| 88 | $this->assetManager->getAssetBundles()[JqueryAsset::class]->jsOptions['position'] |
||
| 89 | ); |
||
| 90 | $this->assertArrayHasKey( |
||
| 91 | 'position', |
||
| 92 | $this->assetManager->getAssetBundles()[Level3Asset::class]->jsOptions |
||
| 93 | ); |
||
| 94 | $this->assertEquals( |
||
| 95 | $pos, |
||
| 96 | $this->assetManager->getAssetBundles()[Level3Asset::class]->jsOptions['position'] |
||
| 97 | ); |
||
| 98 | |||
| 99 | $this->assertEquals( |
||
| 100 | [ |
||
| 101 | 'position' => $pos |
||
| 102 | ], |
||
| 103 | $this->assetManager->getJsFiles()['/js/jquery.js']['attributes'] |
||
| 104 | ); |
||
| 105 | $this->assertEquals( |
||
| 106 | [ |
||
| 107 | 'position' => $pos |
||
| 108 | ], |
||
| 109 | $this->assetManager->getJsFiles()['/files/jsFile.js']['attributes'] |
||
| 110 | ); |
||
| 169 |