| Total Lines | 147 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 | /** |
||
| 136 | * @param BeanDescriptor[] $beanDescriptors |
||
| 137 | */ |
||
| 138 | public function onDaoFactoryGenerated(FileGenerator $fileGenerator, array $beanDescriptors, ConfigurationInterface $configuration): ?FileGenerator |
||
| 139 | { |
||
| 140 | return null; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @param BeanDescriptor[] $beanDescriptors |
||
| 145 | */ |
||
| 146 | public function onDaoFactoryConstructorGenerated(MethodGenerator $methodGenerator, array $beanDescriptors, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 147 | { |
||
| 148 | return null; |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @param BeanDescriptor[] $beanDescriptor |
||
| 153 | */ |
||
| 154 | public function onDaoFactoryGetterGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 155 | { |
||
| 156 | return null; |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @param BeanDescriptor[] $beanDescriptor |
||
| 161 | */ |
||
| 162 | public function onDaoFactorySetterGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 163 | { |
||
| 164 | return null; |
||
| 165 | } |
||
| 166 | }]); |
||
| 167 | $this->method1 = new MethodGenerator(); |
||
| 168 | $this->method2 = new MethodGenerator(); |
||
| 169 | $this->method3 = new MethodGenerator(); |
||
| 170 | $this->method4 = new MethodGenerator(); |
||
| 171 | $this->method5 = new MethodGenerator(); |
||
| 172 | $this->beanDescriptor = $this->getMockBuilder(BeanDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
| 173 | $this->configuration = $this->getMockBuilder(ConfigurationInterface::class)->disableOriginalConstructor()->getMock(); |
||
| 174 | $this->pivotTableMethodsDescriptor = $this->getMockBuilder(PivotTableMethodsDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
| 175 | $this->beanPropertyDescriptor = $this->getMockBuilder(ScalarBeanPropertyDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
| 176 | $this->class = new ClassGenerator(); |
||
| 177 | $this->file = new FileGenerator(); |
||
| 178 | } |
||
| 326 |