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