Conditions | 1 |
Paths | 1 |
Total Lines | 82 |
Code Lines | 52 |
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 |
||
38 | public function providerDAverage(): array |
||
39 | { |
||
40 | return [ |
||
41 | [ |
||
42 | 12, |
||
43 | $this->database1(), |
||
44 | 'Yield', |
||
45 | [ |
||
46 | ['Tree', 'Height'], |
||
47 | ['=Apple', '>10'], |
||
48 | ], |
||
49 | ], |
||
50 | [ |
||
51 | 268333.333333333333, |
||
52 | $this->database2(), |
||
53 | 'Sales', |
||
54 | [ |
||
55 | ['Quarter', 'Sales Rep.'], |
||
56 | ['>1', 'Tina'], |
||
57 | ], |
||
58 | ], |
||
59 | [ |
||
60 | 372500, |
||
61 | $this->database2(), |
||
62 | 'Sales', |
||
63 | [ |
||
64 | ['Quarter', 'Area'], |
||
65 | ['1', 'South'], |
||
66 | ], |
||
67 | ], |
||
68 | 'numeric column, in this case referring to age' => [ |
||
69 | 13, |
||
70 | $this->database1(), |
||
71 | 3, |
||
72 | $this->database1(), |
||
73 | ], |
||
74 | 'null field' => [ |
||
75 | ExcelError::VALUE(), |
||
76 | $this->database1(), |
||
77 | null, |
||
78 | $this->database1(), |
||
79 | ], |
||
80 | 'field unknown column' => [ |
||
81 | ExcelError::VALUE(), |
||
82 | $this->database1(), |
||
83 | 'xyz', |
||
84 | $this->database1(), |
||
85 | ], |
||
86 | 'multiple criteria, omit equal sign' => [ |
||
87 | 10.5, |
||
88 | $this->database1(), |
||
89 | 'Yield', |
||
90 | [ |
||
91 | ['Tree', 'Height'], |
||
92 | ['=Apple', '>10'], |
||
93 | ['Pear'], |
||
94 | ], |
||
95 | ], |
||
96 | 'multiple criteria for same field' => [ |
||
97 | 10, |
||
98 | $this->database1(), |
||
99 | 'Yield', |
||
100 | [ |
||
101 | ['Tree', 'Height', 'Age', 'Height'], |
||
102 | ['=Apple', '>10', null, '<16'], |
||
103 | ], |
||
104 | ], |
||
105 | /* Excel seems to return #NAME? when column number |
||
106 | is too high or too low. This makes so little sense |
||
107 | to me that I'm not going to bother coding that up, |
||
108 | content to return #VALUE! as an invalid name would */ |
||
109 | 'field column number too high' => [ |
||
110 | ExcelError::VALUE(), |
||
111 | $this->database1(), |
||
112 | 99, |
||
113 | $this->database1(), |
||
114 | ], |
||
115 | 'field column number too low' => [ |
||
116 | ExcelError::VALUE(), |
||
117 | $this->database1(), |
||
118 | 0, |
||
119 | $this->database1(), |
||
120 | ], |
||
124 |