Total Lines | 152 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
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 |
||
31 | public function setUp(): void |
||
32 | { |
||
33 | $this->dispatcher = new CodeGeneratorEventDispatcher([new BaseCodeGeneratorListener()]); |
||
34 | $this->nullDispatcher = new CodeGeneratorEventDispatcher([new class () implements CodeGeneratorListenerInterface { |
||
35 | public function onBaseBeanGenerated(FileGenerator $fileGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration): ?FileGenerator |
||
36 | { |
||
37 | return null; |
||
38 | } |
||
39 | |||
40 | public function onBaseBeanConstructorGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
41 | { |
||
42 | return null; |
||
43 | } |
||
44 | |||
45 | public function onBaseBeanPropertyGenerated(?MethodGenerator $getter, ?MethodGenerator $setter, AbstractBeanPropertyDescriptor $propertyDescriptor, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): array |
||
46 | { |
||
47 | return [null, null]; |
||
48 | } |
||
49 | |||
50 | public function onBaseBeanOneToManyGenerated(MethodGenerator $getter, DirectForeignKeyMethodDescriptor $directForeignKeyMethodDescriptor, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
51 | { |
||
52 | return null; |
||
53 | } |
||
54 | |||
55 | public function onBaseBeanManyToManyGenerated(?MethodGenerator $getter, ?MethodGenerator $adder, ?MethodGenerator $remover, ?MethodGenerator $hasser, ?MethodGenerator $setter, PivotTableMethodsDescriptor $pivotTableMethodsDescriptor, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): array |
||
56 | { |
||
57 | return [null, null, null, null, null]; |
||
58 | } |
||
59 | |||
60 | public function onBaseBeanJsonSerializeGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
61 | { |
||
62 | return null; |
||
63 | } |
||
64 | |||
65 | public function onBaseBeanCloneGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
66 | { |
||
67 | return null; |
||
68 | } |
||
69 | |||
70 | public function onBaseDaoGenerated(FileGenerator $fileGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration): ?FileGenerator |
||
71 | { |
||
72 | return null; |
||
73 | } |
||
74 | |||
75 | public function onBaseDaoConstructorGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
76 | { |
||
77 | return null; |
||
78 | } |
||
79 | |||
80 | public function onBaseDaoSaveGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
81 | { |
||
82 | return null; |
||
83 | } |
||
84 | |||
85 | public function onBaseDaoFindAllGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
86 | { |
||
87 | return null; |
||
88 | } |
||
89 | |||
90 | public function onBaseDaoGetByIdGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
91 | { |
||
92 | return null; |
||
93 | } |
||
94 | |||
95 | public function onBaseDaoDeleteGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
96 | { |
||
97 | return null; |
||
98 | } |
||
99 | |||
100 | public function onBaseDaoFindGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
101 | { |
||
102 | return null; |
||
103 | } |
||
104 | |||
105 | public function onBaseDaoFindFromSqlGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
106 | { |
||
107 | return null; |
||
108 | } |
||
109 | |||
110 | public function onBaseDaoFindFromRawSqlGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
111 | { |
||
112 | return null; |
||
113 | } |
||
114 | |||
115 | public function onBaseDaoFindOneGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
116 | { |
||
117 | return null; |
||
118 | } |
||
119 | |||
120 | public function onBaseDaoFindOneFromSqlGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
121 | { |
||
122 | return null; |
||
123 | } |
||
124 | |||
125 | public function onBaseDaoSetDefaultSortGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
126 | { |
||
127 | return null; |
||
128 | } |
||
129 | |||
130 | public function onBaseDaoFindByIndexGenerated(MethodGenerator $methodGenerator, Index $index, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
131 | { |
||
132 | return null; |
||
133 | } |
||
134 | |||
135 | public function onBaseResultIteratorGenerated(FileGenerator $fileGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration): ?FileGenerator |
||
136 | { |
||
137 | return null; |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * @param BeanDescriptor[] $beanDescriptors |
||
142 | */ |
||
143 | public function onDaoFactoryGenerated(FileGenerator $fileGenerator, array $beanDescriptors, ConfigurationInterface $configuration): ?FileGenerator |
||
144 | { |
||
145 | return null; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * @param BeanDescriptor[] $beanDescriptors |
||
150 | */ |
||
151 | public function onDaoFactoryConstructorGenerated(MethodGenerator $methodGenerator, array $beanDescriptors, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
152 | { |
||
153 | return null; |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * @param BeanDescriptor[] $beanDescriptor |
||
158 | */ |
||
159 | public function onDaoFactoryGetterGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
160 | { |
||
161 | return null; |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @param BeanDescriptor[] $beanDescriptor |
||
166 | */ |
||
167 | public function onDaoFactorySetterGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
168 | { |
||
169 | return null; |
||
170 | } |
||
171 | }]); |
||
172 | $this->method1 = new MethodGenerator(); |
||
173 | $this->method2 = new MethodGenerator(); |
||
174 | $this->method3 = new MethodGenerator(); |
||
175 | $this->method4 = new MethodGenerator(); |
||
176 | $this->method5 = new MethodGenerator(); |
||
177 | $this->beanDescriptor = $this->getMockBuilder(BeanDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
178 | $this->configuration = $this->getMockBuilder(ConfigurationInterface::class)->disableOriginalConstructor()->getMock(); |
||
179 | $this->pivotTableMethodsDescriptor = $this->getMockBuilder(PivotTableMethodsDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
180 | $this->beanPropertyDescriptor = $this->getMockBuilder(ScalarBeanPropertyDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
181 | $this->class = new ClassGenerator(); |
||
182 | $this->file = new FileGenerator(); |
||
183 | } |
||
337 |