| Conditions | 1 |
| Paths | 1 |
| Total Lines | 264 |
| 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 |
||
| 35 | public function serviceProvider() |
||
| 36 | { |
||
| 37 | $contentId = 42; |
||
| 38 | $versionNo = 2; |
||
| 39 | $remoteId = md5('One Ring to rule them all'); |
||
| 40 | $language = 'fre-FR'; |
||
| 41 | $userId = 14; |
||
| 42 | $userVersionNo = 5; |
||
| 43 | $copiedContentId = 43; |
||
| 44 | $copiedVersionNo = 1; |
||
| 45 | $copyParentLocationId = 50; |
||
| 46 | $relationDestContentId = 44; |
||
| 47 | |||
| 48 | $contentCreateStruct = new ContentCreateStruct(); |
||
| 49 | $locationCreateStruct = new LocationCreateStruct(); |
||
| 50 | $copyLocationCreateStruct = new LocationCreateStruct( |
||
| 51 | array('parentLocationId' => $copyParentLocationId) |
||
| 52 | ); |
||
| 53 | $contentMetadataUpdateStruct = new ContentMetadataUpdateStruct(); |
||
| 54 | $contentUpdateStruct = new ContentUpdateStruct(); |
||
| 55 | |||
| 56 | $contentType = new ContentType( |
||
| 57 | array( |
||
| 58 | 'fieldDefinitions' => array(), |
||
| 59 | ) |
||
| 60 | ); |
||
| 61 | $contentInfo = $this->getContentInfo($contentId, $remoteId); |
||
| 62 | $versionInfo = $this->getVersionInfo($contentInfo, $versionNo); |
||
| 63 | $content = $this->getContent($versionInfo); |
||
| 64 | |||
| 65 | $user = $this->getUser($userId, md5('Sauron'), $userVersionNo); |
||
| 66 | $usersDraft = array($versionInfo); |
||
| 67 | |||
| 68 | $copiedContent = $this->getContent( |
||
| 69 | $this->getVersionInfo( |
||
| 70 | $this->getContentInfo($copiedContentId, md5('Backup ring, just in case ;-)')), |
||
| 71 | $copiedVersionNo |
||
| 72 | ) |
||
| 73 | ); |
||
| 74 | |||
| 75 | $relations = array(new Relation()); |
||
| 76 | $newRelation = new Relation(); |
||
| 77 | $relationDestContentInfo = $this->getContentInfo($relationDestContentId, md5('Mordor')); |
||
| 78 | |||
| 79 | $translationInfoFilter = array(); |
||
|
|
|||
| 80 | |||
| 81 | return array( |
||
| 82 | array( |
||
| 83 | 'loadContentInfo', |
||
| 84 | array($contentId), |
||
| 85 | $contentInfo, |
||
| 86 | 0, |
||
| 87 | ), |
||
| 88 | array( |
||
| 89 | 'loadContentInfoList', |
||
| 90 | array(array($contentId)), |
||
| 91 | [$contentInfo], |
||
| 92 | 0, |
||
| 93 | ), |
||
| 94 | array( |
||
| 95 | 'loadContentInfoByRemoteId', |
||
| 96 | array($remoteId), |
||
| 97 | $contentInfo, |
||
| 98 | 0, |
||
| 99 | ), |
||
| 100 | array( |
||
| 101 | 'loadVersionInfo', |
||
| 102 | array($contentInfo, $versionNo), |
||
| 103 | $versionInfo, |
||
| 104 | 0, |
||
| 105 | ), |
||
| 106 | array( |
||
| 107 | 'loadVersionInfoById', |
||
| 108 | array($contentId, $versionNo), |
||
| 109 | $versionInfo, |
||
| 110 | 0, |
||
| 111 | ), |
||
| 112 | array( |
||
| 113 | 'loadContentByContentInfo', |
||
| 114 | array($contentInfo, array($language), $versionNo, true), |
||
| 115 | $content, |
||
| 116 | 0, |
||
| 117 | ), |
||
| 118 | array( |
||
| 119 | 'loadContentByVersionInfo', |
||
| 120 | array($versionInfo, array($language), true), |
||
| 121 | $content, |
||
| 122 | 0, |
||
| 123 | ), |
||
| 124 | array( |
||
| 125 | 'loadContent', |
||
| 126 | array($contentId, array($language), $versionNo, true), |
||
| 127 | $content, |
||
| 128 | 0, |
||
| 129 | ), |
||
| 130 | array( |
||
| 131 | 'loadContentByRemoteId', |
||
| 132 | array($remoteId, array($language), $versionNo, true), |
||
| 133 | $content, |
||
| 134 | 0, |
||
| 135 | ), |
||
| 136 | array( |
||
| 137 | 'createContent', |
||
| 138 | array($contentCreateStruct, array($locationCreateStruct)), |
||
| 139 | $content, |
||
| 140 | 1, |
||
| 141 | ContentServiceSignals\CreateContentSignal::class, |
||
| 142 | array( |
||
| 143 | 'contentId' => $contentId, |
||
| 144 | 'versionNo' => $versionNo, |
||
| 145 | ), |
||
| 146 | ), |
||
| 147 | array( |
||
| 148 | 'updateContentMetadata', |
||
| 149 | array($contentInfo, $contentMetadataUpdateStruct), |
||
| 150 | $content, |
||
| 151 | 1, |
||
| 152 | ContentServiceSignals\UpdateContentMetadataSignal::class, |
||
| 153 | array('contentId' => $contentId), |
||
| 154 | ), |
||
| 155 | array( |
||
| 156 | 'deleteContent', |
||
| 157 | array($contentInfo), |
||
| 158 | $contentInfo, |
||
| 159 | 1, |
||
| 160 | ContentServiceSignals\DeleteContentSignal::class, |
||
| 161 | array('contentId' => $contentId), |
||
| 162 | ), |
||
| 163 | array( |
||
| 164 | 'createContentDraft', |
||
| 165 | array($contentInfo, $versionInfo, $user), |
||
| 166 | $content, |
||
| 167 | 1, |
||
| 168 | ContentServiceSignals\CreateContentDraftSignal::class, |
||
| 169 | array( |
||
| 170 | 'contentId' => $contentId, |
||
| 171 | 'versionNo' => $versionNo, |
||
| 172 | 'newVersionNo' => $content->getVersionInfo()->versionNo, |
||
| 173 | 'userId' => $userId, |
||
| 174 | ), |
||
| 175 | ), |
||
| 176 | array( |
||
| 177 | 'loadContentDrafts', |
||
| 178 | array($user), |
||
| 179 | $usersDraft, |
||
| 180 | 0, |
||
| 181 | ), |
||
| 182 | array( |
||
| 183 | 'updateContent', |
||
| 184 | array($versionInfo, $contentUpdateStruct), |
||
| 185 | $content, |
||
| 186 | 1, |
||
| 187 | ContentServiceSignals\UpdateContentSignal::class, |
||
| 188 | array( |
||
| 189 | 'contentId' => $contentId, |
||
| 190 | 'versionNo' => $versionNo, |
||
| 191 | ), |
||
| 192 | ), |
||
| 193 | array( |
||
| 194 | 'publishVersion', |
||
| 195 | array($versionInfo), |
||
| 196 | $content, |
||
| 197 | 1, |
||
| 198 | ContentServiceSignals\PublishVersionSignal::class, |
||
| 199 | array( |
||
| 200 | 'contentId' => $contentId, |
||
| 201 | 'versionNo' => $versionNo, |
||
| 202 | ), |
||
| 203 | ), |
||
| 204 | array( |
||
| 205 | 'deleteVersion', |
||
| 206 | array($versionInfo), |
||
| 207 | $versionInfo, |
||
| 208 | 1, |
||
| 209 | ContentServiceSignals\DeleteVersionSignal::class, |
||
| 210 | array( |
||
| 211 | 'contentId' => $contentId, |
||
| 212 | 'versionNo' => $versionNo, |
||
| 213 | ), |
||
| 214 | ), |
||
| 215 | array( |
||
| 216 | 'loadVersions', |
||
| 217 | array($contentInfo), |
||
| 218 | array($versionInfo), |
||
| 219 | 0, |
||
| 220 | ), |
||
| 221 | array( |
||
| 222 | 'copyContent', |
||
| 223 | array($contentInfo, $copyLocationCreateStruct, $versionInfo), |
||
| 224 | $copiedContent, |
||
| 225 | 1, |
||
| 226 | ContentServiceSignals\CopyContentSignal::class, |
||
| 227 | array( |
||
| 228 | 'srcContentId' => $contentId, |
||
| 229 | 'srcVersionNo' => $versionNo, |
||
| 230 | 'dstContentId' => $copiedContentId, |
||
| 231 | 'dstVersionNo' => $copiedVersionNo, |
||
| 232 | 'dstParentLocationId' => $copyParentLocationId, |
||
| 233 | ), |
||
| 234 | ), |
||
| 235 | array( |
||
| 236 | 'loadRelations', |
||
| 237 | array($versionInfo), |
||
| 238 | $relations, |
||
| 239 | 0, |
||
| 240 | ), |
||
| 241 | array( |
||
| 242 | 'loadReverseRelations', |
||
| 243 | array($contentInfo), |
||
| 244 | $relations, |
||
| 245 | 0, |
||
| 246 | ), |
||
| 247 | array( |
||
| 248 | 'addRelation', |
||
| 249 | array($versionInfo, $relationDestContentInfo), |
||
| 250 | $newRelation, |
||
| 251 | 1, |
||
| 252 | ContentServiceSignals\AddRelationSignal::class, |
||
| 253 | array( |
||
| 254 | 'srcContentId' => $contentId, |
||
| 255 | 'srcVersionNo' => $versionNo, |
||
| 256 | 'dstContentId' => $relationDestContentId, |
||
| 257 | ), |
||
| 258 | ), |
||
| 259 | array( |
||
| 260 | 'deleteRelation', |
||
| 261 | array($versionInfo, $relationDestContentInfo), |
||
| 262 | null, |
||
| 263 | 1, |
||
| 264 | ContentServiceSignals\DeleteRelationSignal::class, |
||
| 265 | array( |
||
| 266 | 'srcContentId' => $contentId, |
||
| 267 | 'srcVersionNo' => $versionNo, |
||
| 268 | 'dstContentId' => $relationDestContentId, |
||
| 269 | ), |
||
| 270 | ), |
||
| 271 | array( |
||
| 272 | 'deleteTranslation', |
||
| 273 | array($contentInfo, $language), |
||
| 274 | null, |
||
| 275 | 2, |
||
| 276 | DeleteTranslationSignal::class, |
||
| 277 | array('contentId' => $contentId, 'languageCode' => $language), |
||
| 278 | ), |
||
| 279 | array( |
||
| 280 | 'newContentCreateStruct', |
||
| 281 | array($contentType, $language), |
||
| 282 | array($contentCreateStruct), |
||
| 283 | 0, |
||
| 284 | ), |
||
| 285 | array( |
||
| 286 | 'newContentMetadataUpdateStruct', |
||
| 287 | array(), |
||
| 288 | array($contentMetadataUpdateStruct), |
||
| 289 | 0, |
||
| 290 | ), |
||
| 291 | array( |
||
| 292 | 'newContentUpdateStruct', |
||
| 293 | array(), |
||
| 294 | array($contentUpdateStruct), |
||
| 295 | 0, |
||
| 296 | ), |
||
| 297 | ); |
||
| 298 | } |
||
| 299 | } |
||
| 300 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.