Conditions | 1 |
Paths | 1 |
Total Lines | 65 |
Code Lines | 49 |
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 |
||
59 | public function testSnap() |
||
60 | { |
||
61 | $rangeField = RangeField::create( |
||
62 | 'TestInt', |
||
63 | 'Test', |
||
64 | 50, |
||
65 | 25, |
||
66 | 75, |
||
67 | ['min' => 25, '17%' => 33, '50%' => 50, '83%' => 66, 'max' => 75] |
||
68 | ); |
||
69 | |||
70 | $rangeField->setSnap(true); |
||
71 | |||
72 | $rangeField->Field([]); |
||
73 | |||
74 | $expected = [ |
||
75 | 'start' => [50], |
||
76 | 'snap' => true, |
||
77 | 'animate' => true, |
||
78 | 'animationDuration' => 300, |
||
79 | 'range' => [ |
||
80 | 'min' => 25, |
||
81 | '17%' => 33, |
||
82 | '50%' => 50, |
||
83 | '83%' => 66, |
||
84 | 'max' => 75 |
||
85 | ], |
||
86 | 'pips' => [ // Show a scale with the slider |
||
87 | 'mode' => 'steps', |
||
88 | 'stepped' => true, |
||
89 | 'density' => 4 |
||
90 | ], |
||
91 | 'unit' => '', |
||
92 | 'decimalPlaces' => 2, |
||
93 | ]; |
||
94 | |||
95 | $this->assertEquals($expected, $rangeField->getData()); |
||
96 | $rangeField->setStep(1); |
||
97 | |||
98 | $rangeField->Field([]); |
||
99 | |||
100 | $expected = [ |
||
101 | 'start' => [50], |
||
102 | 'snap' => true, |
||
103 | 'animate' => true, |
||
104 | 'animationDuration' => 300, |
||
105 | 'step' => 1, |
||
106 | 'range' => [ |
||
107 | 'min' => 25, |
||
108 | '17%' => 33, |
||
109 | '50%' => 50, |
||
110 | '83%' => 66, |
||
111 | 'max' => 75 |
||
112 | ], |
||
113 | 'pips' => [ // Show a scale with the slider |
||
114 | 'mode' => 'steps', |
||
115 | 'stepped' => true, |
||
116 | 'density' => 4 |
||
117 | ], |
||
118 | 'unit' => '', |
||
119 | 'decimalPlaces' => 2, |
||
120 | ]; |
||
121 | |||
122 | $this->assertEquals($expected, $rangeField->getData()); |
||
123 | } |
||
124 | |||
261 |