| Total Lines | 115 |
| Code Lines | 33 |
| 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 |
||
| 32 | public function setUp() |
||
| 33 | { |
||
| 34 | $this->dispatcher = new CodeGeneratorEventDispatcher([new BaseCodeGeneratorListener()]); |
||
| 35 | $this->nullDispatcher = new CodeGeneratorEventDispatcher([new class implements CodeGeneratorListenerInterface { |
||
| 36 | public function onBaseBeanGenerated(FileGenerator $fileGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration): ?FileGenerator |
||
| 37 | { |
||
| 38 | return null; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function onBaseBeanConstructorGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 42 | { |
||
| 43 | return null; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function onBaseBeanPropertyGenerated(?MethodGenerator $getter, ?MethodGenerator $setter, AbstractBeanPropertyDescriptor $propertyDescriptor, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): array |
||
| 47 | { |
||
| 48 | return [null, null]; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function onBaseBeanOneToManyGenerated(MethodGenerator $getter, DirectForeignKeyMethodDescriptor $directForeignKeyMethodDescriptor, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 52 | { |
||
| 53 | return null; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function onBaseBeanManyToManyGenerated(?MethodGenerator $getter, ?MethodGenerator $adder, ?MethodGenerator $remover, ?MethodGenerator $hasser, ?MethodGenerator $setter, PivotTableMethodsDescriptor $pivotTableMethodsDescriptor, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): array |
||
| 57 | { |
||
| 58 | return [null, null, null, null, null]; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function onBaseBeanJsonSerializeGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 62 | { |
||
| 63 | return null; |
||
| 64 | } |
||
| 65 | |||
| 66 | public function onBaseBeanCloneGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 67 | { |
||
| 68 | return null; |
||
| 69 | } |
||
| 70 | |||
| 71 | public function onBaseDaoGenerated(FileGenerator $fileGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration): ?FileGenerator |
||
| 72 | { |
||
| 73 | return null; |
||
| 74 | } |
||
| 75 | |||
| 76 | public function onBaseDaoConstructorGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 77 | { |
||
| 78 | return null; |
||
| 79 | } |
||
| 80 | |||
| 81 | public function onBaseDaoSaveGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 82 | { |
||
| 83 | return null; |
||
| 84 | } |
||
| 85 | |||
| 86 | public function onBaseDaoFindAllGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 87 | { |
||
| 88 | return null; |
||
| 89 | } |
||
| 90 | |||
| 91 | public function onBaseDaoGetByIdGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 92 | { |
||
| 93 | return null; |
||
| 94 | } |
||
| 95 | |||
| 96 | public function onBaseDaoDeleteGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 97 | { |
||
| 98 | return null; |
||
| 99 | } |
||
| 100 | |||
| 101 | public function onBaseDaoFindGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 102 | { |
||
| 103 | return null; |
||
| 104 | } |
||
| 105 | |||
| 106 | public function onBaseDaoFindFromSqlGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 107 | { |
||
| 108 | return null; |
||
| 109 | } |
||
| 110 | |||
| 111 | public function onBaseDaoFindFromRawSqlGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 112 | { |
||
| 113 | return null; |
||
| 114 | } |
||
| 115 | |||
| 116 | public function onBaseDaoFindOneGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 117 | { |
||
| 118 | return null; |
||
| 119 | } |
||
| 120 | |||
| 121 | public function onBaseDaoFindOneFromSqlGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 122 | { |
||
| 123 | return null; |
||
| 124 | } |
||
| 125 | |||
| 126 | public function onBaseDaoSetDefaultSortGenerated(MethodGenerator $methodGenerator, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 127 | { |
||
| 128 | return null; |
||
| 129 | } |
||
| 130 | |||
| 131 | public function onBaseDaoFindByIndexGenerated(MethodGenerator $methodGenerator, Index $index, BeanDescriptor $beanDescriptor, ConfigurationInterface $configuration, ClassGenerator $classGenerator): ?MethodGenerator |
||
| 132 | { |
||
| 133 | return null; |
||
| 134 | } |
||
| 135 | }]); |
||
| 136 | $this->method1 = new MethodGenerator(); |
||
| 137 | $this->method2 = new MethodGenerator(); |
||
| 138 | $this->method3 = new MethodGenerator(); |
||
| 139 | $this->method4 = new MethodGenerator(); |
||
| 140 | $this->method5 = new MethodGenerator(); |
||
| 141 | $this->beanDescriptor = $this->getMockBuilder(BeanDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
| 142 | $this->configuration = $this->getMockBuilder(ConfigurationInterface::class)->disableOriginalConstructor()->getMock(); |
||
| 143 | $this->pivotTableMethodsDescriptor = $this->getMockBuilder(PivotTableMethodsDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
| 144 | $this->beanPropertyDescriptor = $this->getMockBuilder(ScalarBeanPropertyDescriptor::class)->disableOriginalConstructor()->getMock(); |
||
| 145 | $this->class = new ClassGenerator(); |
||
| 146 | $this->file = new FileGenerator(); |
||
| 147 | } |
||
| 271 |