| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 53 | public function testSnap() |
||
| 54 | { |
||
| 55 | $rangeField = RangeField::create( |
||
| 56 | 'TestInt', |
||
| 57 | 'Test', |
||
| 58 | 50, |
||
| 59 | 25, |
||
| 60 | 75, |
||
| 61 | ['min' => 25, '17%' => 33, '50%' => 50, '83%' => 66, 'max' => 75] |
||
| 62 | ); |
||
| 63 | |||
| 64 | $rangeField->setSnap(true); |
||
| 65 | |||
| 66 | $rangeField->Field([]); |
||
| 67 | |||
| 68 | $expected = [ |
||
| 69 | 'start' => [50], |
||
| 70 | 'snap' => true, |
||
| 71 | 'range' => [ |
||
| 72 | 'min' => 25, |
||
| 73 | '17%' => 33, |
||
| 74 | '50%' => 50, |
||
| 75 | '83%' => 66, |
||
| 76 | 'max' => 75 |
||
| 77 | ], |
||
| 78 | 'pips' => [ // Show a scale with the slider |
||
| 79 | 'mode' => 'steps', |
||
| 80 | 'stepped' => true, |
||
| 81 | 'density' => 4 |
||
| 82 | ] |
||
| 83 | ]; |
||
| 84 | |||
| 85 | $this->assertEquals($expected, $rangeField->getData()); |
||
| 86 | $rangeField->setStep(1); |
||
| 87 | |||
| 88 | $rangeField->Field([]); |
||
| 89 | |||
| 90 | $expected = [ |
||
| 91 | 'start' => [50], |
||
| 92 | 'snap' => false, |
||
| 93 | 'step' => 1, |
||
| 94 | 'range' => [ |
||
| 95 | 'min' => 25, |
||
| 96 | '17%' => 33, |
||
| 97 | '50%' => 50, |
||
| 98 | '83%' => 66, |
||
| 99 | 'max' => 75 |
||
| 100 | ], |
||
| 101 | 'pips' => [ // Show a scale with the slider |
||
| 102 | 'mode' => 'steps', |
||
| 103 | 'stepped' => true, |
||
| 104 | 'density' => 4 |
||
| 105 | ] |
||
| 106 | ]; |
||
| 107 | |||
| 108 | $this->assertEquals($expected, $rangeField->getData()); |
||
| 109 | } |
||
| 110 | |||
| 209 |