Conditions | 4 |
Paths | 4 |
Total Lines | 56 |
Code Lines | 44 |
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 |
||
30 | { |
||
31 | $this->regenerateUsersOrders(); |
||
32 | } |
||
33 | |||
34 | public function testWithConfigFile() |
||
35 | { |
||
36 | $generator = new ChainGeneratorFactory(); |
||
37 | $generator->addFactory(new ConstantGeneratorFactory()) |
||
38 | ->addFactory(new FakerGeneratorFactory()); |
||
39 | |||
40 | $command = (new Application('Database anonymizer', '0.0.1')) |
||
41 | ->add(new AnonymizeCommand($generator)); |
||
42 | |||
43 | $commandTester = new CommandTester($command); |
||
44 | $commandTester->setInputs(array('y')); |
||
45 | $commandTester->execute([ |
||
46 | 'command' => $command->getName(), |
||
47 | '--config' => realpath(__DIR__.'/../../config/config.yaml'), |
||
48 | '--type' => $GLOBALS['db_type'], |
||
49 | '--host' => $GLOBALS['db_host'], |
||
50 | '--port' => $GLOBALS['db_port'], |
||
51 | '--database' => $GLOBALS['db_name'], |
||
52 | '--user' => $GLOBALS['db_username'], |
||
53 | '--password' => $GLOBALS['db_password'], |
||
54 | ]); |
||
55 | |||
56 | $this->doTestValues(); |
||
57 | } |
||
58 | |||
59 | public function testWithAnnotations() |
||
60 | { |
||
61 | $generator = new ChainGeneratorFactory(); |
||
62 | $generator->addFactory(new ConstantGeneratorFactory()) |
||
63 | ->addFactory(new FakerGeneratorFactory()); |
||
64 | |||
65 | $annotationReader = new AnnotationReader(); |
||
66 | $configGuesser = new ConfigGuesser(); |
||
67 | $annotationConfigFactory = new AnnotationConfigFactory($annotationReader, $configGuesser); |
||
68 | $anonymizeCommand = new AnonymizeCommand($generator); |
||
69 | $anonymizeCommand->enableAnnotations($annotationConfigFactory); |
||
70 | |||
71 | $registry = new Registry(); |
||
72 | |||
73 | $command = (new Application('Database anonymizer', '0.0.1')) |
||
74 | ->add($anonymizeCommand); |
||
75 | |||
76 | $commandTester = new CommandTester($command); |
||
77 | $commandTester->setInputs(array('y')); |
||
78 | $commandTester->execute([ |
||
79 | 'command' => $command->getName(), |
||
80 | '--annotations' => true, |
||
81 | '--em' => 'default', |
||
82 | ]); |
||
83 | |||
84 | $this->doTestValues(); |
||
85 | } |
||
86 | |||
128 |