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