Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
23 | { |
||
24 | public function testSingleManagers() |
||
25 | { |
||
26 | $settings = [ |
||
27 | 'entity_manager' => [ |
||
28 | 'connection' => [ |
||
29 | 'driver' => 'pdo_sqlite', |
||
30 | 'memory' => true, |
||
31 | ], |
||
32 | 'metadata_mapping' => [ |
||
33 | [ |
||
34 | 'type' => ManagerBuilder::METADATA_MAPPING_ANNOTATION, |
||
35 | 'path' => __DIR__, |
||
36 | ], |
||
37 | ], |
||
38 | ], |
||
39 | 'mongodb_document_manager' => [ |
||
40 | 'connection' => [ |
||
41 | 'server' => 'mongodb://localhost:27017', |
||
42 | 'options' => ['connect' => false], |
||
43 | ], |
||
44 | 'metadata_mapping' => [ |
||
45 | [ |
||
46 | 'type' => ManagerBuilder::METADATA_MAPPING_ANNOTATION, |
||
47 | 'path' => __DIR__, |
||
48 | ], |
||
49 | ], |
||
50 | ], |
||
51 | 'couchdb_document_manager' => [ |
||
52 | 'connection' => [ |
||
53 | 'host' => 'localhost', |
||
54 | 'dbname' => 'doctrine', |
||
55 | ], |
||
56 | 'metadata_mapping' => [ |
||
57 | [ |
||
58 | 'type' => ManagerBuilder::METADATA_MAPPING_ANNOTATION, |
||
59 | 'path' => __DIR__, |
||
60 | ], |
||
61 | ], |
||
62 | ], |
||
63 | ]; |
||
64 | |||
65 | $managerBuilder = (new ManagerBuilder())->loadSettings($settings); |
||
66 | |||
67 | $managers = $managerBuilder->getManagers(); |
||
68 | |||
69 | self::assertCount(3, $managers); |
||
70 | |||
71 | self::assertInstanceOf(EntityManager::class, $managerBuilder->getManager('entityManager')); |
||
72 | self::assertEquals($managers['entityManager'], $managerBuilder->getManager('entityManager')); |
||
73 | |||
74 | self::assertInstanceOf(MongoDBDocumentManager::class, $managerBuilder->getManager('mongoDocumentManager')); |
||
75 | self::assertEquals($managers['mongoDocumentManager'], $managerBuilder->getManager('mongoDocumentManager')); |
||
76 | |||
77 | self::assertInstanceOf(CouchDBDocumentManager::class, $managerBuilder->getManager('couchDocumentManager')); |
||
78 | self::assertEquals($managers['couchDocumentManager'], $managerBuilder->getManager('couchDocumentManager')); |
||
79 | } |
||
204 |