Conditions | 3 |
Paths | 3 |
Total Lines | 109 |
Code Lines | 53 |
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 |
||
30 | public function typesDataProvider(): array |
||
31 | { |
||
32 | $data = [ |
||
33 | // #0 |
||
34 | [ |
||
35 | DynamicRoutesUnitTest::TYPES_ROUTE_CATALOG_INT_BAR, |
||
36 | '/catalog/1/', |
||
37 | 1 |
||
38 | ], |
||
39 | // #1 |
||
40 | [ |
||
41 | DynamicRoutesUnitTest::TYPES_ROUTE_CATALOG_INT_BAR, |
||
42 | '/catalog/-1/', |
||
43 | - 1 |
||
44 | ], |
||
45 | // #2 |
||
46 | [ |
||
47 | DynamicRoutesUnitTest::TYPES_ROUTE_CATALOG_INT_BAR, |
||
48 | '/catalog/+1/', |
||
49 | 1 |
||
50 | ], |
||
51 | // #3 |
||
52 | [ |
||
53 | DynamicRoutesUnitTest::TYPES_ROUTE_CATALOG_FIX_POINT_BAR, |
||
54 | '/catalog/1.1/', |
||
55 | 1.1 |
||
56 | ], |
||
57 | // #4 |
||
58 | [ |
||
59 | DynamicRoutesUnitTest::TYPES_ROUTE_CATALOG_FIX_POINT_BAR, |
||
60 | '/catalog/-1.1/', |
||
61 | - 1.1 |
||
62 | ], |
||
63 | // #5 |
||
64 | [ |
||
65 | DynamicRoutesUnitTest::TYPES_ROUTE_CATALOG_FIX_POINT_BAR, |
||
66 | '/catalog/+1.1/', |
||
67 | 1.1 |
||
68 | ], |
||
69 | // #6 |
||
70 | [ |
||
71 | '/[a:bar]/', |
||
72 | '/.-@/', |
||
73 | '.-@' |
||
74 | ], |
||
75 | // #7 |
||
76 | [ |
||
77 | '/[s:bar]/', |
||
78 | '/, ;:/', |
||
79 | ', ;:' |
||
80 | ], |
||
81 | // #8 |
||
82 | [ |
||
83 | [ |
||
84 | '/[fp:number]/', |
||
85 | '/[s:bar]/' |
||
86 | ], |
||
87 | '/abc/', |
||
88 | 'abc' |
||
89 | ], |
||
90 | // #9 |
||
91 | [ |
||
92 | '/catalog/[il:bar]/', |
||
93 | '/catalog/123,456,789/', |
||
94 | '123,456,789' |
||
95 | ], |
||
96 | // #10 |
||
97 | [ |
||
98 | '/catalog/[s:bar]/', |
||
99 | '/catalog/123&456/', |
||
100 | '123&456' |
||
101 | ], |
||
102 | // #11, parameter name chars testing |
||
103 | [ |
||
104 | '/[s:Aa_x-0]/', |
||
105 | '/abc123/', |
||
106 | 'abc123', |
||
107 | 'Aa_x-0' |
||
108 | ], |
||
109 | // #12, date type testing 1 |
||
110 | [ |
||
111 | '/[date:dfield]/', |
||
112 | '/2020-02-02/', |
||
113 | '2020-02-02', |
||
114 | 'dfield' |
||
115 | ], |
||
116 | // #13, date type testing 2 |
||
117 | [ |
||
118 | '/posts-[date:dfield]/', |
||
119 | '/posts-2020-02-02/', |
||
120 | '2020-02-02', |
||
121 | 'dfield' |
||
122 | ] |
||
123 | ]; |
||
124 | |||
125 | $return = []; |
||
126 | |||
127 | foreach (Router::getListOfSupportedRequestMethods() as $method) { |
||
128 | $tmp = array_merge($data); |
||
129 | |||
130 | foreach ($tmp as $item) { |
||
131 | $item = array_merge([ |
||
132 | $method |
||
133 | ], $item); |
||
134 | $return[] = $item; |
||
135 | } |
||
136 | } |
||
137 | |||
138 | return $return; |
||
139 | } |
||
198 |