| Conditions | 1 |
| Paths | 1 |
| Total Lines | 165 |
| 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 serviceProvider() |
||
| 35 | { |
||
| 36 | $objectStateGroupId = 4; |
||
| 37 | $objectStateId = 42; |
||
| 38 | $priority = 50; |
||
| 39 | $contentId = 59; |
||
| 40 | $contentRemoteId = md5("What's up doc ?"); |
||
| 41 | |||
| 42 | $objectStateGroupCreateStruct = new ObjectStateGroupCreateStruct(); |
||
| 43 | $objectStateGroupUpdateStruct = new ObjectStateGroupUpdateStruct(); |
||
| 44 | $objectStateCreateStruct = new ObjectStateCreateStruct(); |
||
| 45 | $objectStateUpdateStruct = new ObjectStateUpdateStruct(); |
||
| 46 | $objectStateGroup = new ObjectStateGroup( |
||
| 47 | array( |
||
| 48 | 'id' => $objectStateGroupId, |
||
| 49 | ) |
||
| 50 | ); |
||
| 51 | $objectState = new ObjectState( |
||
| 52 | array( |
||
| 53 | 'id' => $objectStateId, |
||
| 54 | ) |
||
| 55 | ); |
||
| 56 | $contentInfo = $this->getContentInfo($contentId, $contentRemoteId); |
||
| 57 | |||
| 58 | return [ |
||
| 59 | [ |
||
| 60 | 'createObjectStateGroup', |
||
| 61 | [$objectStateGroupCreateStruct], |
||
| 62 | $objectStateGroup, |
||
| 63 | 1, |
||
| 64 | ObjectStateServiceSignals\CreateObjectStateGroupSignal::class, |
||
| 65 | ['objectStateGroupId' => $objectStateGroupId], |
||
| 66 | ], |
||
| 67 | [ |
||
| 68 | 'loadObjectStateGroup', |
||
| 69 | [4, []], |
||
| 70 | $objectStateGroup, |
||
| 71 | 0, |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | 'loadObjectStateGroups', |
||
| 75 | [1, 1, []], |
||
| 76 | [$objectStateGroup], |
||
| 77 | 0, |
||
| 78 | ], |
||
| 79 | [ |
||
| 80 | 'loadObjectStates', |
||
| 81 | [$objectStateGroup, []], |
||
| 82 | [$objectState], |
||
| 83 | 0, |
||
| 84 | ], |
||
| 85 | [ |
||
| 86 | 'updateObjectStateGroup', |
||
| 87 | [$objectStateGroup, $objectStateGroupUpdateStruct], |
||
| 88 | $objectStateGroup, |
||
| 89 | 1, |
||
| 90 | ObjectStateServiceSignals\UpdateObjectStateGroupSignal::class, |
||
| 91 | ['objectStateGroupId' => $objectStateGroupId], |
||
| 92 | ], |
||
| 93 | [ |
||
| 94 | 'deleteObjectStateGroup', |
||
| 95 | [$objectStateGroup], |
||
| 96 | null, |
||
| 97 | 1, |
||
| 98 | ObjectStateServiceSignals\DeleteObjectStateGroupSignal::class, |
||
| 99 | ['objectStateGroupId' => $objectStateGroupId], |
||
| 100 | ], |
||
| 101 | [ |
||
| 102 | 'createObjectState', |
||
| 103 | [$objectStateGroup, $objectStateCreateStruct], |
||
| 104 | $objectState, |
||
| 105 | 1, |
||
| 106 | ObjectStateServiceSignals\CreateObjectStateSignal::class, |
||
| 107 | [ |
||
| 108 | 'objectStateGroupId' => $objectStateGroupId, |
||
| 109 | 'objectStateId' => $objectStateId, |
||
| 110 | ], |
||
| 111 | ], |
||
| 112 | [ |
||
| 113 | 'loadObjectState', |
||
| 114 | [$objectStateId, []], |
||
| 115 | $objectState, |
||
| 116 | 0, |
||
| 117 | ], |
||
| 118 | [ |
||
| 119 | 'updateObjectState', |
||
| 120 | [$objectState, $objectStateUpdateStruct], |
||
| 121 | $objectState, |
||
| 122 | 1, |
||
| 123 | ObjectStateServiceSignals\UpdateObjectStateSignal::class, |
||
| 124 | [ |
||
| 125 | 'objectStateId' => $objectStateId, |
||
| 126 | ], |
||
| 127 | ], |
||
| 128 | [ |
||
| 129 | 'setPriorityOfObjectState', |
||
| 130 | [$objectState, $priority], |
||
| 131 | null, |
||
| 132 | 1, |
||
| 133 | ObjectStateServiceSignals\SetPriorityOfObjectStateSignal::class, |
||
| 134 | [ |
||
| 135 | 'objectStateId' => $objectStateId, |
||
| 136 | 'priority' => $priority, |
||
| 137 | ], |
||
| 138 | ], |
||
| 139 | [ |
||
| 140 | 'deleteObjectState', |
||
| 141 | [$objectState], |
||
| 142 | null, |
||
| 143 | 1, |
||
| 144 | ObjectStateServiceSignals\DeleteObjectStateSignal::class, |
||
| 145 | [ |
||
| 146 | 'objectStateId' => $objectStateId, |
||
| 147 | ], |
||
| 148 | ], |
||
| 149 | [ |
||
| 150 | 'setContentState', |
||
| 151 | [$contentInfo, $objectStateGroup, $objectState], |
||
| 152 | null, |
||
| 153 | 1, |
||
| 154 | ObjectStateServiceSignals\SetContentStateSignal::class, |
||
| 155 | [ |
||
| 156 | 'objectStateId' => $objectStateId, |
||
| 157 | 'contentId' => $contentId, |
||
| 158 | 'objectStateGroupId' => $objectStateGroupId, |
||
| 159 | ], |
||
| 160 | ], |
||
| 161 | [ |
||
| 162 | 'getContentState', |
||
| 163 | [$contentInfo, $objectStateGroup], |
||
| 164 | $objectState, |
||
| 165 | 0, |
||
| 166 | ], |
||
| 167 | [ |
||
| 168 | 'getContentCount', |
||
| 169 | [$objectState], |
||
| 170 | 35, |
||
| 171 | 0, |
||
| 172 | ], |
||
| 173 | [ |
||
| 174 | 'newObjectStateGroupCreateStruct', |
||
| 175 | ['identifier'], |
||
| 176 | $objectStateGroupCreateStruct, |
||
| 177 | 0, |
||
| 178 | ], |
||
| 179 | [ |
||
| 180 | 'newObjectStateGroupUpdateStruct', |
||
| 181 | [], |
||
| 182 | $objectStateGroupUpdateStruct, |
||
| 183 | 0, |
||
| 184 | ], |
||
| 185 | [ |
||
| 186 | 'newObjectStateUpdateStruct', |
||
| 187 | [], |
||
| 188 | $objectStateUpdateStruct, |
||
| 189 | 0, |
||
| 190 | ], |
||
| 191 | [ |
||
| 192 | 'newObjectStateCreateStruct', |
||
| 193 | ['identifier'], |
||
| 194 | $objectStateCreateStruct, |
||
| 195 | 0, |
||
| 196 | ], |
||
| 197 | ]; |
||
| 198 | } |
||
| 199 | } |
||
| 200 |