| Conditions | 2 |
| Paths | 2 |
| Total Lines | 170 |
| Code Lines | 121 |
| 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 |
||
| 120 | public function testExistingConfig() |
||
| 121 | { |
||
| 122 | $this->provider->getCurrentConfig()->willReturn([ |
||
| 123 | '\\Zend\\ServiceManager\\AbstractFactory\\ConfigAbstractFactory' => [ |
||
| 124 | 'AddSuperAction' => [ |
||
| 125 | EntityManagerInterface::class, |
||
| 126 | '\\Zend\\Hydrator\\ClassMethods', |
||
| 127 | 'SuperInputFilter', |
||
| 128 | '\\Psr\\Log\\LoggerInterface', |
||
| 129 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 130 | ], |
||
| 131 | 'UpdateSuperAction' => [ |
||
| 132 | EntityManagerInterface::class, |
||
| 133 | '\\Zend\\Hydrator\\ClassMethods', |
||
| 134 | 'SuperInputFilter', |
||
| 135 | '\\Psr\\Log\\LoggerInterface', |
||
| 136 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 137 | ], |
||
| 138 | 'GetSuperAction' => [ |
||
| 139 | EntityManagerInterface::class, |
||
| 140 | '\\Psr\\Log\\LoggerInterface', |
||
| 141 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 142 | ], |
||
| 143 | 'GetsSuperAction' => [ |
||
| 144 | EntityManagerInterface::class, |
||
| 145 | '\\Psr\\Log\\LoggerInterface', |
||
| 146 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 147 | ], |
||
| 148 | 'DeleteSuperAction' => [ |
||
| 149 | EntityManagerInterface::class, |
||
| 150 | '\\Psr\\Log\\LoggerInterface', |
||
| 151 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 152 | ], |
||
| 153 | ], |
||
| 154 | 'dependencies' => [ |
||
| 155 | 'delegators' => [ |
||
| 156 | '\\Zend\\Expressive\\Application' => [ |
||
| 157 | 'Routes', |
||
| 158 | ], |
||
| 159 | ], |
||
| 160 | ], |
||
| 161 | 'doctrine' => [ |
||
| 162 | 'paths' => [ |
||
| 163 | 'src/Dummy/Entities' |
||
| 164 | ], |
||
| 165 | ], |
||
| 166 | 'input_filter_specs' => [ |
||
| 167 | 'SuperInputFilter' => [ |
||
| 168 | 'bar' => [ |
||
| 169 | 'required' => true, |
||
| 170 | ], |
||
| 171 | 'baz' => [ |
||
| 172 | 'required' => true, |
||
| 173 | ], |
||
| 174 | ], |
||
| 175 | ], |
||
| 176 | ]); |
||
| 177 | $this->provider->getConfigNameSpace()->willReturn('A\C'); |
||
| 178 | |||
| 179 | $configGenerator = new Config($this->provider->reveal()); |
||
| 180 | $value = $configGenerator->generate(); |
||
| 181 | |||
| 182 | $root = vfsStream::setup(); |
||
| 183 | file_put_contents($root->url() . '/dummyProvider.php', $value); |
||
| 184 | try { |
||
| 185 | include $root->url() . '/dummyProvider.php'; |
||
| 186 | } catch (\ParseError $exception) { |
||
| 187 | echo 'File', PHP_EOL, $this->getPrintableFile($value), PHP_EOL; |
||
| 188 | throw $exception; |
||
| 189 | } |
||
| 190 | |||
| 191 | $class = $configGenerator->getClassName(); |
||
| 192 | $config = new $class(); |
||
| 193 | |||
| 194 | $actual = call_user_func($config); |
||
| 195 | |||
| 196 | $expected = [ |
||
| 197 | '\\Zend\\ServiceManager\\AbstractFactory\\ConfigAbstractFactory' => [ |
||
| 198 | 'AddSuperAction' => [ |
||
| 199 | EntityManagerInterface::class, |
||
| 200 | '\\Zend\\Hydrator\\ClassMethods', |
||
| 201 | 'SuperInputFilter', |
||
| 202 | '\\Psr\\Log\\LoggerInterface', |
||
| 203 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 204 | ], |
||
| 205 | 'UpdateSuperAction' => [ |
||
| 206 | EntityManagerInterface::class, |
||
| 207 | '\\Zend\\Hydrator\\ClassMethods', |
||
| 208 | 'SuperInputFilter', |
||
| 209 | '\\Psr\\Log\\LoggerInterface', |
||
| 210 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 211 | ], |
||
| 212 | 'GetSuperAction' => [ |
||
| 213 | EntityManagerInterface::class, |
||
| 214 | '\\Psr\\Log\\LoggerInterface', |
||
| 215 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 216 | ], |
||
| 217 | 'GetsSuperAction' => [ |
||
| 218 | EntityManagerInterface::class, |
||
| 219 | '\\Psr\\Log\\LoggerInterface', |
||
| 220 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 221 | ], |
||
| 222 | 'DeleteSuperAction' => [ |
||
| 223 | EntityManagerInterface::class, |
||
| 224 | '\\Psr\\Log\\LoggerInterface', |
||
| 225 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 226 | ], |
||
| 227 | 'AddDummyAction' => [ |
||
| 228 | EntityManagerInterface::class, |
||
| 229 | '\\Zend\\Hydrator\\ClassMethods', |
||
| 230 | 'DummyInputFilter', |
||
| 231 | '\\Psr\\Log\\LoggerInterface', |
||
| 232 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 233 | ], |
||
| 234 | 'UpdateDummyAction' => [ |
||
| 235 | EntityManagerInterface::class, |
||
| 236 | '\\Zend\\Hydrator\\ClassMethods', |
||
| 237 | 'DummyInputFilter', |
||
| 238 | '\\Psr\\Log\\LoggerInterface', |
||
| 239 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 240 | ], |
||
| 241 | 'GetDummyAction' => [ |
||
| 242 | EntityManagerInterface::class, |
||
| 243 | '\\Psr\\Log\\LoggerInterface', |
||
| 244 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 245 | ], |
||
| 246 | 'GetsDummyAction' => [ |
||
| 247 | EntityManagerInterface::class, |
||
| 248 | '\\Psr\\Log\\LoggerInterface', |
||
| 249 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 250 | ], |
||
| 251 | 'DeleteDummyAction' => [ |
||
| 252 | EntityManagerInterface::class, |
||
| 253 | '\\Psr\\Log\\LoggerInterface', |
||
| 254 | '\\SlayerBirden\\DataFlowServer\\Extractor\\RecursiveEntitiesExtractor', |
||
| 255 | ], |
||
| 256 | ], |
||
| 257 | 'dependencies' => [ |
||
| 258 | 'delegators' => [ |
||
| 259 | '\\Zend\\Expressive\\Application' => [ |
||
| 260 | 'Routes', |
||
| 261 | ], |
||
| 262 | ], |
||
| 263 | ], |
||
| 264 | 'doctrine' => [ |
||
| 265 | 'paths' => [ |
||
| 266 | 'src/Dummy/Entities' |
||
| 267 | ], |
||
| 268 | ], |
||
| 269 | 'input_filter_specs' => [ |
||
| 270 | 'SuperInputFilter' => [ |
||
| 271 | 'bar' => [ |
||
| 272 | 'required' => true, |
||
| 273 | ], |
||
| 274 | 'baz' => [ |
||
| 275 | 'required' => true, |
||
| 276 | ], |
||
| 277 | ], |
||
| 278 | 'DummyInputFilter' => [ |
||
| 279 | 'bar' => [ |
||
| 280 | 'required' => true, |
||
| 281 | ], |
||
| 282 | 'baz' => [ |
||
| 283 | 'required' => true, |
||
| 284 | ], |
||
| 285 | ], |
||
| 286 | ], |
||
| 287 | ]; |
||
| 288 | |||
| 289 | $this->assertEquals($expected, $actual); |
||
| 290 | } |
||
| 297 |