| Conditions | 2 |
| Paths | 2 |
| Total Lines | 53 |
| 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 |
||
| 123 | public function testMenu2LinkingMode() |
||
| 124 | { |
||
| 125 | $this->logInWithPermission('ADMIN'); |
||
| 126 | |||
| 127 | SSViewer::set_themes(null); |
||
|
|
|||
| 128 | |||
| 129 | $reflection = new \ReflectionClass(FilesystemPublisher::class); |
||
| 130 | $urlToPath = $reflection->getMethod('URLtoPath'); |
||
| 131 | $urlToPath->setAccessible(true); |
||
| 132 | |||
| 133 | $fsp = FilesystemPublisher::create() |
||
| 134 | ->setDestFolder('cache/testing/'); |
||
| 135 | |||
| 136 | $level1 = StaticPublisherTestPage::create(); |
||
| 137 | $level1->URLSegment = 'test-level-1'; |
||
| 138 | $level1->write(); |
||
| 139 | $level1->publishRecursive(); |
||
| 140 | |||
| 141 | $level2_1 = StaticPublisherTestPage::create(); |
||
| 142 | $level2_1->URLSegment = 'test-level-2-1'; |
||
| 143 | $level2_1->ParentID = $level1->ID; |
||
| 144 | $level2_1->write(); |
||
| 145 | $level2_1->publishRecursive(); |
||
| 146 | |||
| 147 | $fsp->publishURL($level1->Link(), true); |
||
| 148 | $fsp->publishURL($level2_1->Link(), true); |
||
| 149 | $static2_1FilePath = $fsp->getDestPath().$urlToPath->invokeArgs($fsp, [$level2_1->Link()]); |
||
| 150 | |||
| 151 | $this->assertFileExists($static2_1FilePath); |
||
| 152 | $this->assertContains( |
||
| 153 | 'current', |
||
| 154 | file_get_contents($static2_1FilePath) |
||
| 155 | ); |
||
| 156 | |||
| 157 | $level2_2 = new StaticPublisherTestPage(); |
||
| 158 | $level2_2->URLSegment = 'test-level-2-2'; |
||
| 159 | $level2_2->ParentID = $level1->ID; |
||
| 160 | $level2_2->write(); |
||
| 161 | $level2_2->publishRecursive(); |
||
| 162 | |||
| 163 | $fsp->publishURL($level2_2->Link(), true); |
||
| 164 | $static2_2FilePath = $fsp->getDestPath().$urlToPath->invokeArgs($fsp, [$level2_2->Link()]); |
||
| 165 | |||
| 166 | $this->assertFileExists($static2_2FilePath); |
||
| 167 | $this->assertContains( |
||
| 168 | 'linkcurrent', |
||
| 169 | file_get_contents($static2_2FilePath) |
||
| 170 | ); |
||
| 171 | |||
| 172 | if (file_exists($fsp->getDestPath())) { |
||
| 173 | Filesystem::removeFolder($fsp->getDestPath()); |
||
| 174 | } |
||
| 175 | } |
||
| 176 | |||
| 202 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: