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