| Conditions | 1 |
| Paths | 1 |
| Total Lines | 66 |
| 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 |
||
| 18 | public function createXmlBundleTestContainer() : ContainerBuilder |
||
| 19 | { |
||
| 20 | $container = new ContainerBuilder(new ParameterBag([ |
||
| 21 | 'kernel.name' => 'app', |
||
| 22 | 'kernel.debug' => false, |
||
| 23 | 'kernel.bundles' => ['XmlBundle' => 'Fixtures\Bundles\XmlBundle\XmlBundle'], |
||
| 24 | 'kernel.cache_dir' => sys_get_temp_dir(), |
||
| 25 | 'kernel.environment' => 'test', |
||
| 26 | 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir |
||
| 27 | 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir |
||
| 28 | 'kernel.bundles_metadata' => [], |
||
| 29 | 'container.build_id' => uniqid(), |
||
| 30 | ])); |
||
| 31 | $container->set('annotation_reader', new AnnotationReader()); |
||
| 32 | |||
| 33 | $extension = new DoctrineExtension(); |
||
| 34 | $container->registerExtension($extension); |
||
| 35 | $extension->load([ |
||
| 36 | [ |
||
| 37 | 'dbal' => [ |
||
| 38 | 'connections' => [ |
||
| 39 | 'default' => [ |
||
| 40 | 'driver' => 'pdo_mysql', |
||
| 41 | 'charset' => 'UTF8', |
||
| 42 | 'platform-service' => 'my.platform', |
||
| 43 | ], |
||
| 44 | ], |
||
| 45 | 'default_connection' => 'default', |
||
| 46 | 'types' => [ |
||
| 47 | 'test' => [ |
||
| 48 | 'class' => TestType::class, |
||
| 49 | ], |
||
| 50 | ], |
||
| 51 | ], |
||
| 52 | 'orm' => [ |
||
| 53 | 'default_entity_manager' => 'default', |
||
| 54 | 'entity_managers' => [ |
||
| 55 | 'default' => [ |
||
| 56 | 'mappings' => [ |
||
| 57 | 'XmlBundle' => [ |
||
| 58 | 'type' => 'xml', |
||
| 59 | 'dir' => __DIR__ . '/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine', |
||
| 60 | 'prefix' => 'Fixtures\Bundles\XmlBundle\Entity', |
||
| 61 | ], |
||
| 62 | ], |
||
| 63 | ], |
||
| 64 | ], |
||
| 65 | 'resolve_target_entities' => ['Symfony\Component\Security\Core\User\UserInterface' => 'stdClass'], |
||
| 66 | ], |
||
| 67 | ], |
||
| 68 | ], $container); |
||
| 69 | |||
| 70 | $container->setDefinition('my.platform', new Definition('Doctrine\DBAL\Platforms\MySqlPlatform'))->setPublic(true); |
||
| 71 | |||
| 72 | // Register dummy cache services so we don't have to load the FrameworkExtension |
||
| 73 | $container->setDefinition('cache.system', (new Definition(ArrayAdapter::class))->setPublic(true)); |
||
| 74 | $container->setDefinition('cache.app', (new Definition(ArrayAdapter::class))->setPublic(true)); |
||
| 75 | |||
| 76 | $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveChildDefinitionsPass()]); |
||
| 77 | $container->getCompilerPassConfig()->setRemovingPasses([]); |
||
| 78 | // make all Doctrine services public, so we can fetch them in the test |
||
| 79 | $container->getCompilerPassConfig()->addPass(new TestCaseAllPublicCompilerPass()); |
||
| 80 | $container->compile(); |
||
| 81 | |||
| 82 | return $container; |
||
| 83 | } |
||
| 84 | } |
||
| 107 |