Conditions | 1 |
Paths | 1 |
Total Lines | 57 |
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 |
||
27 | public function createYamlBundleTestContainer() |
||
28 | { |
||
29 | $container = new ContainerBuilder(new ParameterBag([ |
||
30 | 'kernel.name' => 'app', |
||
31 | 'kernel.debug' => false, |
||
32 | 'kernel.bundles' => ['YamlBundle' => 'Fixtures\Bundles\YamlBundle\YamlBundle'], |
||
33 | 'kernel.cache_dir' => sys_get_temp_dir(), |
||
34 | 'kernel.environment' => 'test', |
||
35 | 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir |
||
36 | ])); |
||
37 | $container->set('annotation_reader', new AnnotationReader()); |
||
38 | $extension = new DoctrineExtension(); |
||
39 | $container->registerExtension($extension); |
||
40 | $extension->load([[ |
||
41 | 'dbal' => [ |
||
42 | 'connections' => [ |
||
43 | 'default' => [ |
||
44 | 'driver' => 'pdo_mysql', |
||
45 | 'charset' => 'UTF8', |
||
46 | 'platform-service' => 'my.platform', |
||
47 | ], |
||
48 | ], |
||
49 | 'default_connection' => 'default', |
||
50 | 'types' => [ |
||
51 | 'test' => [ |
||
52 | 'class' => TestType::class, |
||
53 | 'commented' => false, |
||
54 | ], |
||
55 | ], |
||
56 | ], 'orm' => [ |
||
57 | 'default_entity_manager' => 'default', |
||
58 | 'entity_managers' => [ |
||
59 | 'default' => [ |
||
60 | 'mappings' => [ |
||
61 | 'YamlBundle' => [ |
||
62 | 'type' => 'yml', |
||
63 | 'dir' => __DIR__ . '/DependencyInjection/Fixtures/Bundles/YamlBundle/Resources/config/doctrine', |
||
64 | 'prefix' => 'Fixtures\Bundles\YamlBundle\Entity', |
||
65 | ], |
||
66 | ], |
||
67 | ], |
||
68 | ], |
||
69 | 'resolve_target_entities' => ['Symfony\Component\Security\Core\User\UserInterface' => 'stdClass'], |
||
70 | ], |
||
71 | ], |
||
72 | ], $container); |
||
73 | |||
74 | $container->setDefinition('my.platform', new Definition('Doctrine\DBAL\Platforms\MySqlPlatform'))->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 |