| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 43 |
| 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 |
||
| 73 | public function testChangingControlsDeepNest(): void |
||
| 74 | { |
||
| 75 | $con1 = new Controls\Text(); // filled from adapter |
||
| 76 | $con1->set('foo', 'zgv'); |
||
| 77 | $con1->addRule(IRules::IS_NOT_EMPTY, 'must not be empty'); |
||
| 78 | $con2 = new Controls\Text(); // filled from adapter |
||
| 79 | $con2->set('bar'); |
||
| 80 | $con2->addRule(IRules::IS_NOT_EMPTY, 'must not be empty'); |
||
| 81 | $con3 = new Controls\Text(); // never filled |
||
| 82 | $con3->set('bvt'); |
||
| 83 | $con3->addRule(IRules::IS_NOT_EMPTY, 'must not be empty'); |
||
| 84 | $con4 = new Controls\Text(); // filled from adapter |
||
| 85 | $con4->set('sgg'); |
||
| 86 | $con4->addRule(IRules::IS_NOT_EMPTY, 'must not be empty'); |
||
| 87 | |||
| 88 | $input3 = new Controls\AnyControl(); |
||
| 89 | $input3->addControl('sgg', $con4); |
||
| 90 | $input3->addControl('bvt', $con3); |
||
| 91 | $input2 = new Controls\AnyControl(); |
||
| 92 | $input2->addControl('bar', $con2); |
||
| 93 | $input2->addControl('mor', $input3); |
||
| 94 | $input = new Controls\AnyControl(); |
||
| 95 | $input->addControl('ext', $input2); |
||
| 96 | $input->addControl('foo', $con1); |
||
| 97 | |||
| 98 | $adapter = new \Adapter(); |
||
| 99 | $form = new Form('testing'); |
||
| 100 | $form->addControlDefaultKey($input); |
||
| 101 | $form->setInputs($adapter); |
||
| 102 | |||
| 103 | $input->needAll(true); |
||
| 104 | $input2->needAll(true); |
||
| 105 | $input3->needAll(true); |
||
| 106 | $form->setSentValues(); |
||
| 107 | $this->assertFalse($form->isValid()); |
||
| 108 | |||
| 109 | $input3->needAll(false); |
||
| 110 | $form->setSentValues(); |
||
| 111 | $this->assertTrue($form->isValid()); |
||
| 112 | |||
| 113 | $input2->needAll(false); |
||
| 114 | $form->setSentValues(); |
||
| 115 | $this->assertTrue($form->isValid()); |
||
| 116 | |||
| 117 | $input->needAll(false); |
||
| 118 | $form->setSentValues(); |
||
| 119 | $this->assertTrue($form->isValid()); |
||
| 120 | |||
| 121 | $input->needAll(true); |
||
| 122 | $input3->needAll(true); |
||
| 123 | $form->setSentValues(); |
||
| 124 | $this->assertTrue($form->isValid()); |
||
| 125 | } |
||
| 198 |