| Conditions | 1 |
| Paths | 1 |
| Total Lines | 197 |
| 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 |
||
| 32 | public function serviceProvider() |
||
| 33 | { |
||
| 34 | $rootId = 2; |
||
| 35 | $rootPath = '/1/2'; |
||
| 36 | $rootContentId = 57; |
||
| 37 | $rootContentRemoteId = md5('content root'); |
||
| 38 | $rootRemoteId = md5('root'); |
||
| 39 | $locationId = 60; |
||
| 40 | $locationPath = '/1/2/60'; |
||
| 41 | $locationContentId = 59; |
||
| 42 | $locationContentRemoteId = md5('not content root'); |
||
| 43 | $locationRemoteId = md5('not root'); |
||
| 44 | |||
| 45 | $rootContentInfo = $this->getContentInfo($rootContentId, $rootContentRemoteId); |
||
| 46 | $root = new Location( |
||
| 47 | array( |
||
| 48 | 'id' => $rootId, |
||
| 49 | 'path' => $rootPath, |
||
| 50 | 'remoteId' => $rootRemoteId, |
||
| 51 | 'contentInfo' => $rootContentInfo, |
||
| 52 | 'parentLocationId' => 1, |
||
| 53 | ) |
||
| 54 | ); |
||
| 55 | $locationContentInfo = $this->getContentInfo($locationContentId, $locationContentRemoteId); |
||
| 56 | $location = new Location( |
||
| 57 | array( |
||
| 58 | 'id' => $locationId, |
||
| 59 | 'path' => $locationPath, |
||
| 60 | 'remoteId' => $locationRemoteId, |
||
| 61 | 'contentInfo' => $locationContentInfo, |
||
| 62 | 'parentLocationId' => $rootId, |
||
| 63 | ) |
||
| 64 | ); |
||
| 65 | |||
| 66 | $rootChildren = new LocationList( |
||
| 67 | array( |
||
| 68 | 'totalCount' => 1, |
||
| 69 | 'locations' => array($location), |
||
| 70 | ) |
||
| 71 | ); |
||
| 72 | |||
| 73 | $locationCreateStruct = new LocationCreateStruct(); |
||
| 74 | $locationUpdateStruct = new LocationUpdateStruct(); |
||
| 75 | |||
| 76 | return array( |
||
| 77 | array( |
||
| 78 | 'copySubtree', |
||
| 79 | array($location, $root), |
||
| 80 | $location, |
||
| 81 | 1, |
||
| 82 | LocationServiceSignals\CopySubtreeSignal::class, |
||
| 83 | array( |
||
| 84 | 'subtreeId' => $locationId, |
||
| 85 | 'targetParentLocationId' => $rootId, |
||
| 86 | ), |
||
| 87 | ), |
||
| 88 | array( |
||
| 89 | 'loadLocation', |
||
| 90 | array($rootId, [], true), |
||
| 91 | $root, |
||
| 92 | 0, |
||
| 93 | ), |
||
| 94 | array( |
||
| 95 | 'loadLocationList', |
||
| 96 | array([$rootId], [], true), |
||
| 97 | [$root], |
||
| 98 | 0, |
||
| 99 | ), |
||
| 100 | array( |
||
| 101 | 'loadLocationByRemoteId', |
||
| 102 | array($rootRemoteId, [], true), |
||
| 103 | $root, |
||
| 104 | 0, |
||
| 105 | ), |
||
| 106 | array( |
||
| 107 | 'loadLocations', |
||
| 108 | array($locationContentInfo, $root, []), |
||
| 109 | array($location), |
||
| 110 | 0, |
||
| 111 | ), |
||
| 112 | array( |
||
| 113 | 'loadLocationChildren', |
||
| 114 | array($root, 0, 1, []), |
||
| 115 | $rootChildren, |
||
| 116 | 0, |
||
| 117 | ), |
||
| 118 | /*array( |
||
| 119 | 'loadParentLocationsForDraftContent', |
||
| 120 | array($root, 0, 1, []), |
||
| 121 | $rootChildren, |
||
| 122 | 0, |
||
| 123 | ),*/ |
||
| 124 | array( |
||
| 125 | 'getLocationChildCount', |
||
| 126 | array($root), |
||
| 127 | 1, |
||
| 128 | 0, |
||
| 129 | ), |
||
| 130 | array( |
||
| 131 | 'createLocation', |
||
| 132 | array($locationContentInfo, $locationCreateStruct), |
||
| 133 | $location, |
||
| 134 | 1, |
||
| 135 | LocationServiceSignals\CreateLocationSignal::class, |
||
| 136 | array( |
||
| 137 | 'contentId' => $locationContentId, |
||
| 138 | 'locationId' => $locationId, |
||
| 139 | 'parentLocationId' => $rootId, |
||
| 140 | ), |
||
| 141 | ), |
||
| 142 | array( |
||
| 143 | 'updateLocation', |
||
| 144 | array($location, $locationUpdateStruct), |
||
| 145 | $location, |
||
| 146 | 1, |
||
| 147 | LocationServiceSignals\UpdateLocationSignal::class, |
||
| 148 | array( |
||
| 149 | 'contentId' => $locationContentId, |
||
| 150 | 'locationId' => $locationId, |
||
| 151 | 'parentLocationId' => $rootId, |
||
| 152 | ), |
||
| 153 | ), |
||
| 154 | array( |
||
| 155 | 'swapLocation', |
||
| 156 | array($location, $root), |
||
| 157 | null, |
||
| 158 | 1, |
||
| 159 | LocationServiceSignals\SwapLocationSignal::class, |
||
| 160 | array( |
||
| 161 | 'location1Id' => $locationId, |
||
| 162 | 'content1Id' => $locationContentId, |
||
| 163 | 'parentLocation1Id' => $rootId, |
||
| 164 | 'location2Id' => $rootId, |
||
| 165 | 'content2Id' => $rootContentId, |
||
| 166 | 'parentLocation2Id' => 1, |
||
| 167 | ), |
||
| 168 | ), |
||
| 169 | array( |
||
| 170 | 'hideLocation', |
||
| 171 | array($location), |
||
| 172 | $location, |
||
| 173 | 1, |
||
| 174 | LocationServiceSignals\HideLocationSignal::class, |
||
| 175 | array( |
||
| 176 | 'locationId' => $locationId, |
||
| 177 | 'parentLocationId' => $rootId, |
||
| 178 | ), |
||
| 179 | ), |
||
| 180 | array( |
||
| 181 | 'unhideLocation', |
||
| 182 | array($location), |
||
| 183 | $location, |
||
| 184 | 1, |
||
| 185 | LocationServiceSignals\UnhideLocationSignal::class, |
||
| 186 | array( |
||
| 187 | 'locationId' => $locationId, |
||
| 188 | 'parentLocationId' => $rootId, |
||
| 189 | ), |
||
| 190 | ), |
||
| 191 | array( |
||
| 192 | 'moveSubtree', |
||
| 193 | array($location, $root), |
||
| 194 | $location, |
||
| 195 | 1, |
||
| 196 | LocationServiceSignals\MoveSubtreeSignal::class, |
||
| 197 | array( |
||
| 198 | 'locationId' => $locationId, |
||
| 199 | 'newParentLocationId' => $rootId, |
||
| 200 | 'oldParentLocationId' => $rootId, |
||
| 201 | ), |
||
| 202 | ), |
||
| 203 | array( |
||
| 204 | 'deleteLocation', |
||
| 205 | array($location), |
||
| 206 | null, |
||
| 207 | 1, |
||
| 208 | LocationServiceSignals\DeleteLocationSignal::class, |
||
| 209 | array( |
||
| 210 | 'locationId' => $locationId, |
||
| 211 | 'contentId' => $locationContentId, |
||
| 212 | 'parentLocationId' => $rootId, |
||
| 213 | ), |
||
| 214 | ), |
||
| 215 | array( |
||
| 216 | 'newLocationCreateStruct', |
||
| 217 | array($rootId, null), |
||
| 218 | $locationCreateStruct, |
||
| 219 | 0, |
||
| 220 | ), |
||
| 221 | array( |
||
| 222 | 'newLocationUpdateStruct', |
||
| 223 | array(), |
||
| 224 | $locationUpdateStruct, |
||
| 225 | 0, |
||
| 226 | ), |
||
| 227 | ); |
||
| 228 | } |
||
| 229 | } |
||
| 230 |