Conditions | 1 |
Paths | 1 |
Total Lines | 64 |
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() |
||
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 | 'dbal' => [ |
||
37 | 'connections' => [ |
||
38 | 'default' => [ |
||
39 | 'driver' => 'pdo_mysql', |
||
40 | 'charset' => 'UTF8', |
||
41 | 'platform-service' => 'my.platform', |
||
42 | ], |
||
43 | ], |
||
44 | 'default_connection' => 'default', |
||
45 | 'types' => [ |
||
46 | 'test' => [ |
||
47 | 'class' => TestType::class, |
||
48 | ], |
||
49 | ], |
||
50 | ], 'orm' => [ |
||
51 | 'default_entity_manager' => 'default', |
||
52 | 'entity_managers' => [ |
||
53 | 'default' => [ |
||
54 | 'mappings' => [ |
||
55 | 'XmlBundle' => [ |
||
56 | 'type' => 'xml', |
||
57 | 'dir' => __DIR__ . '/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine', |
||
58 | 'prefix' => 'Fixtures\Bundles\XmlBundle\Entity', |
||
59 | ], |
||
60 | ], |
||
61 | ], |
||
62 | ], |
||
63 | 'resolve_target_entities' => ['Symfony\Component\Security\Core\User\UserInterface' => 'stdClass'], |
||
64 | ], |
||
65 | ], |
||
66 | ], $container); |
||
67 | |||
68 | $container->setDefinition('my.platform', new Definition('Doctrine\DBAL\Platforms\MySqlPlatform'))->setPublic(true); |
||
69 | |||
70 | // Register dummy cache services so we don't have to load the FrameworkExtension |
||
71 | $container->setDefinition('cache.system', (new Definition(ArrayAdapter::class))->setPublic(true)); |
||
72 | $container->setDefinition('cache.app', (new Definition(ArrayAdapter::class))->setPublic(true)); |
||
73 | |||
74 | $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveChildDefinitionsPass()]); |
||
75 | $container->getCompilerPassConfig()->setRemovingPasses([]); |
||
76 | // make all Doctrine services public, so we can fetch them in the test |
||
77 | $container->getCompilerPassConfig()->addPass(new TestCaseAllPublicCompilerPass()); |
||
78 | $container->compile(); |
||
79 | |||
80 | return $container; |
||
81 | } |
||
82 | } |
||
105 |