| Conditions | 1 |
| Paths | 1 |
| Total Lines | 160 |
| 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 |
||
| 55 | public function providerForTestViewRequest() |
||
| 56 | { |
||
| 57 | $foo = new stdClass(); |
||
| 58 | $foo->name = uniqid('View test content foo'); |
||
| 59 | $foo->remoteId = md5($foo->name); |
||
| 60 | |||
| 61 | $bar = new stdClass(); |
||
| 62 | $bar->name = uniqid('View test content bar'); |
||
| 63 | $bar->remoteId = md5($bar->name); |
||
| 64 | |||
| 65 | return [ |
||
| 66 | [ |
||
| 67 | <<< XML |
||
| 68 | <?xml version="1.0" encoding="UTF-8"?> |
||
| 69 | <ViewInput> |
||
| 70 | <identifier>TitleView</identifier> |
||
| 71 | <Query> |
||
| 72 | <Filter> |
||
| 73 | <OR> |
||
| 74 | <ContentRemoteIdCriterion>{$foo->remoteId}</ContentRemoteIdCriterion> |
||
| 75 | <ContentRemoteIdCriterion>{$bar->remoteId}</ContentRemoteIdCriterion> |
||
| 76 | </OR> |
||
| 77 | </Filter> |
||
| 78 | <limit>10</limit> |
||
| 79 | <offset>0</offset> |
||
| 80 | </Query> |
||
| 81 | </ViewInput> |
||
| 82 | XML |
||
| 83 | , |
||
| 84 | 'xml', |
||
| 85 | 2, |
||
| 86 | [$foo, $bar], |
||
| 87 | ], |
||
| 88 | [ |
||
| 89 | <<< JSON |
||
| 90 | { |
||
| 91 | "ViewInput": { |
||
| 92 | "identifier": "TitleView", |
||
| 93 | "Query": { |
||
| 94 | "Filter": { |
||
| 95 | "OR": { |
||
| 96 | "ContentRemoteIdCriterion": [ |
||
| 97 | "{$foo->remoteId}", |
||
| 98 | "{$bar->remoteId}" |
||
| 99 | ] |
||
| 100 | } |
||
| 101 | }, |
||
| 102 | "limit": "10", |
||
| 103 | "offset": "0" |
||
| 104 | } |
||
| 105 | } |
||
| 106 | } |
||
| 107 | JSON |
||
| 108 | , |
||
| 109 | 'json', |
||
| 110 | 2, |
||
| 111 | [$foo, $bar], |
||
| 112 | ], |
||
| 113 | [ |
||
| 114 | <<< XML |
||
| 115 | <?xml version="1.0" encoding="UTF-8"?> |
||
| 116 | <ViewInput> |
||
| 117 | <identifier>TitleView</identifier> |
||
| 118 | <Query> |
||
| 119 | <Filter> |
||
| 120 | <AND> |
||
| 121 | <OR> |
||
| 122 | <ContentRemoteIdCriterion>{$foo->remoteId}</ContentRemoteIdCriterion> |
||
| 123 | <ContentRemoteIdCriterion>{$bar->remoteId}</ContentRemoteIdCriterion> |
||
| 124 | </OR> |
||
| 125 | <ContentRemoteIdCriterion>{$foo->remoteId}</ContentRemoteIdCriterion> |
||
| 126 | </AND> |
||
| 127 | </Filter> |
||
| 128 | <limit>10</limit> |
||
| 129 | <offset>0</offset> |
||
| 130 | </Query> |
||
| 131 | </ViewInput> |
||
| 132 | XML |
||
| 133 | , |
||
| 134 | 'xml', |
||
| 135 | 1, |
||
| 136 | [$foo, $bar], |
||
| 137 | ], |
||
| 138 | [ |
||
| 139 | <<< JSON |
||
| 140 | { |
||
| 141 | "ViewInput": { |
||
| 142 | "identifier": "TitleView", |
||
| 143 | "public": true, |
||
| 144 | "Query": { |
||
| 145 | "Filter": { |
||
| 146 | "OR": [ |
||
| 147 | { |
||
| 148 | "ContentRemoteIdCriterion": "{$foo->remoteId}" |
||
| 149 | }, |
||
| 150 | { |
||
| 151 | "ContentRemoteIdCriterion": "{$bar->remoteId}" |
||
| 152 | } |
||
| 153 | ] |
||
| 154 | }, |
||
| 155 | "FacetBuilders": {}, |
||
| 156 | "SortClauses": {}, |
||
| 157 | "limit": 1000, |
||
| 158 | "offset": 0 |
||
| 159 | } |
||
| 160 | } |
||
| 161 | } |
||
| 162 | JSON |
||
| 163 | , |
||
| 164 | 'json', |
||
| 165 | 2, |
||
| 166 | [$foo, $bar], |
||
| 167 | ], |
||
| 168 | [ |
||
| 169 | <<< JSON |
||
| 170 | { |
||
| 171 | "ViewInput": { |
||
| 172 | "identifier": "udw-locations-by-parent-location-id-1", |
||
| 173 | "public": false, |
||
| 174 | "Query": { |
||
| 175 | "Criteria": {}, |
||
| 176 | "FacetBuilders": {}, |
||
| 177 | "SortClauses": {}, |
||
| 178 | "Filter": { |
||
| 179 | "AND": [ |
||
| 180 | { |
||
| 181 | "OR": [ |
||
| 182 | { |
||
| 183 | "ContentTypeIdentifierCriterion": "folder" |
||
| 184 | }, |
||
| 185 | { |
||
| 186 | "ContentTypeIdentifierCriterion": "article" |
||
| 187 | } |
||
| 188 | ] |
||
| 189 | }, |
||
| 190 | { |
||
| 191 | "OR": [ |
||
| 192 | { |
||
| 193 | "ContentRemoteIdCriterion": "{$foo->remoteId}" |
||
| 194 | }, |
||
| 195 | { |
||
| 196 | "ContentRemoteIdCriterion": "{$bar->remoteId}" |
||
| 197 | } |
||
| 198 | ] |
||
| 199 | } |
||
| 200 | ] |
||
| 201 | }, |
||
| 202 | "limit": 50, |
||
| 203 | "offset": 0 |
||
| 204 | } |
||
| 205 | } |
||
| 206 | } |
||
| 207 | JSON |
||
| 208 | , |
||
| 209 | 'json', |
||
| 210 | 2, |
||
| 211 | [$foo, $bar], |
||
| 212 | ], |
||
| 213 | ]; |
||
| 214 | } |
||
| 215 | |||
| 236 |