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