| Conditions | 1 |
| Paths | 1 |
| Total Lines | 117 |
| 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 |
||
| 30 | public function serviceProvider() |
||
| 31 | { |
||
| 32 | $locationId = 60; |
||
| 33 | $locationPath = '/bugs-bunny'; |
||
| 34 | $locationRemoteId = md5('bugs bunny'); |
||
| 35 | |||
| 36 | $urlAliasId = '42-foobar'; |
||
| 37 | $globalUrlAliasId = 'rabbit'; |
||
| 38 | $path = '/lapin'; |
||
| 39 | $globalPath = '/lapins'; |
||
| 40 | $globalDestination = '/characters/rabbits'; |
||
| 41 | $languageCode = 'fre-FR'; |
||
| 42 | $forward = true; |
||
| 43 | $alwaysAvailable = true; |
||
| 44 | |||
| 45 | $contentInfo = $this->getContentInfo(59, md5('bugs bunny contnet')); |
||
| 46 | |||
| 47 | $location = new Location( |
||
| 48 | array( |
||
| 49 | 'id' => $locationId, |
||
| 50 | 'path' => $locationPath, |
||
| 51 | 'remoteId' => $locationRemoteId, |
||
| 52 | 'contentInfo' => $contentInfo, |
||
| 53 | ) |
||
| 54 | ); |
||
| 55 | |||
| 56 | $locationUrlAlias = new URLAlias( |
||
| 57 | array( |
||
| 58 | 'id' => $urlAliasId, |
||
| 59 | 'type' => URLAlias::LOCATION, |
||
| 60 | 'destination' => $locationId, |
||
| 61 | 'path' => $path, |
||
| 62 | 'languageCodes' => array($languageCode), |
||
| 63 | 'forward' => $forward, |
||
| 64 | ) |
||
| 65 | ); |
||
| 66 | |||
| 67 | $globalUrlAlias = new URLAlias( |
||
| 68 | array( |
||
| 69 | 'id' => $globalUrlAliasId, |
||
| 70 | 'type' => URLAlias::RESOURCE, |
||
| 71 | 'destination' => $globalDestination, |
||
| 72 | 'path' => $globalPath, |
||
| 73 | 'languageCodes' => array($languageCode), |
||
| 74 | 'forward' => $forward, |
||
| 75 | ) |
||
| 76 | ); |
||
| 77 | |||
| 78 | $aliasList = array($globalUrlAlias, $locationUrlAlias); |
||
| 79 | |||
| 80 | return array( |
||
| 81 | array( |
||
| 82 | 'createUrlAlias', |
||
| 83 | array( |
||
| 84 | $location, $path, $languageCode, $forward, $alwaysAvailable, |
||
| 85 | ), |
||
| 86 | $locationUrlAlias, |
||
| 87 | 1, |
||
| 88 | URLAliasServiceSignals\CreateUrlAliasSignal::class, |
||
| 89 | array('urlAliasId' => $urlAliasId), |
||
| 90 | ), |
||
| 91 | array( |
||
| 92 | 'createGlobalUrlAlias', |
||
| 93 | array( |
||
| 94 | $globalPath, |
||
| 95 | $globalDestination, |
||
| 96 | $languageCode, |
||
| 97 | $forward, |
||
| 98 | $alwaysAvailable, |
||
| 99 | ), |
||
| 100 | $globalUrlAlias, |
||
| 101 | 1, |
||
| 102 | URLAliasServiceSignals\CreateGlobalUrlAliasSignal::class, |
||
| 103 | array('urlAliasId' => $globalUrlAliasId), |
||
| 104 | ), |
||
| 105 | array( |
||
| 106 | 'listLocationAliases', |
||
| 107 | array($location, false, $languageCode, false, array()), |
||
| 108 | array($locationUrlAlias), |
||
| 109 | 0, |
||
| 110 | ), |
||
| 111 | array( |
||
| 112 | 'listGlobalAliases', |
||
| 113 | array($languageCode, 1, 2), |
||
| 114 | array($globalUrlAlias), |
||
| 115 | 0, |
||
| 116 | ), |
||
| 117 | array( |
||
| 118 | 'removeAliases', |
||
| 119 | array($aliasList), |
||
| 120 | null, |
||
| 121 | 1, |
||
| 122 | URLAliasServiceSignals\RemoveAliasesSignal::class, |
||
| 123 | array( |
||
| 124 | 'aliasList' => $aliasList, |
||
| 125 | ), |
||
| 126 | ), |
||
| 127 | array( |
||
| 128 | 'lookup', |
||
| 129 | array($path, $languageCode), |
||
| 130 | $locationUrlAlias, |
||
| 131 | 0, |
||
| 132 | ), |
||
| 133 | array( |
||
| 134 | 'reverseLookup', |
||
| 135 | array($location, $languageCode, false, array()), |
||
| 136 | $locationUrlAlias, |
||
| 137 | 0, |
||
| 138 | ), |
||
| 139 | array( |
||
| 140 | 'load', |
||
| 141 | array($urlAliasId), |
||
| 142 | $locationUrlAlias, |
||
| 143 | 0, |
||
| 144 | ), |
||
| 145 | ); |
||
| 146 | } |
||
| 147 | } |
||
| 148 |