| Conditions | 1 |
| Paths | 1 |
| Total Lines | 119 |
| 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 | $newParentLocationId = 2; |
||
| 37 | $trashItemId = $locationId = 60; |
||
| 38 | $contentId = 59; |
||
| 39 | $trashItemContentInfo = $this->getContentInfo($contentId, md5('trash')); |
||
| 40 | $trashItemParentLocationId = 17; |
||
| 41 | |||
| 42 | $trashItem = new TrashItem( |
||
| 43 | array( |
||
| 44 | 'id' => $trashItemId, |
||
| 45 | 'contentInfo' => $trashItemContentInfo, |
||
| 46 | 'parentLocationId' => $trashItemParentLocationId, |
||
| 47 | ) |
||
| 48 | ); |
||
| 49 | |||
| 50 | $newParentLocation = new Location( |
||
| 51 | array( |
||
| 52 | 'id' => $newParentLocationId, |
||
| 53 | 'contentInfo' => $this->getContentInfo(53, md5('root')), |
||
| 54 | ) |
||
| 55 | ); |
||
| 56 | |||
| 57 | $location = new Location( |
||
| 58 | array( |
||
| 59 | 'id' => $locationId, |
||
| 60 | 'contentInfo' => $trashItemContentInfo, |
||
| 61 | 'parentLocationId' => $trashItemParentLocationId, |
||
| 62 | ) |
||
| 63 | ); |
||
| 64 | |||
| 65 | $locationWithNewParent = new Location( |
||
| 66 | array( |
||
| 67 | 'id' => $locationId, |
||
| 68 | 'contentInfo' => $trashItemContentInfo, |
||
| 69 | 'parentLocationId' => $newParentLocationId, |
||
| 70 | ) |
||
| 71 | ); |
||
| 72 | |||
| 73 | $trashItemDeleteResult = new TrashItemDeleteResult( |
||
| 74 | array( |
||
| 75 | 'trashItemId' => $trashItemId, |
||
| 76 | 'contentId' => $contentId, |
||
| 77 | 'contentRemoved' => true, |
||
| 78 | ) |
||
| 79 | ); |
||
| 80 | |||
| 81 | $trashItemDeleteResultList = new TrashItemDeleteResultList( |
||
| 82 | array( |
||
| 83 | 'items' => array($trashItemDeleteResult), |
||
| 84 | ) |
||
| 85 | ); |
||
| 86 | |||
| 87 | return array( |
||
| 88 | array( |
||
| 89 | 'loadTrashItem', |
||
| 90 | array($trashItemId), |
||
| 91 | $trashItem, |
||
| 92 | 0, |
||
| 93 | ), |
||
| 94 | array( |
||
| 95 | 'trash', |
||
| 96 | array($location), |
||
| 97 | $trashItem, |
||
| 98 | 1, |
||
| 99 | TrashServiceSignals\TrashSignal::class, |
||
| 100 | array('locationId' => $locationId), |
||
| 101 | ), |
||
| 102 | array( |
||
| 103 | 'recover', |
||
| 104 | array($trashItem, $newParentLocation), |
||
| 105 | $locationWithNewParent, |
||
| 106 | 1, |
||
| 107 | 'eZ\Publish\Core\SignalSlot\Signal\TrashService\RecoverSignal', |
||
| 108 | array( |
||
| 109 | 'trashItemId' => $trashItemId, |
||
| 110 | 'newParentLocationId' => $newParentLocationId, |
||
| 111 | 'newLocationId' => $locationId, |
||
| 112 | ), |
||
| 113 | ), |
||
| 114 | array( |
||
| 115 | 'recover', |
||
| 116 | array($trashItem, null), |
||
| 117 | $location, |
||
| 118 | 1, |
||
| 119 | TrashServiceSignals\RecoverSignal::class, |
||
| 120 | array( |
||
| 121 | 'trashItemId' => $trashItemId, |
||
| 122 | 'newParentLocationId' => $trashItemParentLocationId, |
||
| 123 | 'newLocationId' => $locationId, |
||
| 124 | ), |
||
| 125 | ), |
||
| 126 | array( |
||
| 127 | 'emptyTrash', |
||
| 128 | array(), |
||
| 129 | $trashItemDeleteResultList, |
||
| 130 | 1, |
||
| 131 | TrashServiceSignals\EmptyTrashSignal::class, |
||
| 132 | array('trashItemDeleteResultList' => $trashItemDeleteResultList), |
||
| 133 | ), |
||
| 134 | array( |
||
| 135 | 'deleteTrashItem', |
||
| 136 | array($trashItem), |
||
| 137 | $trashItemDeleteResult, |
||
| 138 | 1, |
||
| 139 | TrashServiceSignals\DeleteTrashItemSignal::class, |
||
| 140 | array( |
||
| 141 | 'trashItemId' => $trashItemId, |
||
| 142 | 'trashItemDeleteResult' => $trashItemDeleteResult, |
||
| 143 | ), |
||
| 144 | ), |
||
| 145 | array( |
||
| 146 | 'findTrashItems', |
||
| 147 | array(new Query()), |
||
| 148 | new SearchResult(array('totalCount' => 0)), |
||
| 149 | 0, |
||
| 150 | ), |
||
| 151 | ); |
||
| 152 | } |
||
| 153 | } |
||
| 154 |