Conditions | 13 |
Paths | 10 |
Total Lines | 46 |
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 |
||
131 | protected function appendFirstUriPartIfValidDimension(&$path) |
||
132 | { |
||
133 | $requestPath = ltrim($this->controllerContext->getRequest()->getHttpRequest()->getUri()->getPath(), '/'); |
||
134 | $matches = []; |
||
135 | preg_match(FrontendNodeRoutePartHandler::DIMENSION_REQUEST_PATH_MATCHER, $requestPath, $matches); |
||
136 | if (!isset($matches['firstUriPart']) && !isset($matches['dimensionPresetUriSegments'])) { |
||
137 | return; |
||
138 | } |
||
139 | |||
140 | $dimensionPresets = $this->contentDimensionPresetSource->getAllPresets(); |
||
141 | if (count($dimensionPresets) === 0) { |
||
142 | return; |
||
143 | } |
||
144 | |||
145 | $firstUriPartExploded = explode('_', $matches['firstUriPart'] ?: $matches['dimensionPresetUriSegments']); |
||
146 | if ($this->supportEmptySegmentForDimensions) { |
||
147 | foreach ($firstUriPartExploded as $uriSegment) { |
||
148 | $uriSegmentIsValid = false; |
||
149 | foreach ($dimensionPresets as $dimensionName => $dimensionPreset) { |
||
150 | $preset = $this->contentDimensionPresetSource->findPresetByUriSegment($dimensionName, $uriSegment); |
||
151 | if ($preset !== null) { |
||
152 | $uriSegmentIsValid = true; |
||
153 | break; |
||
154 | } |
||
155 | } |
||
156 | if (!$uriSegmentIsValid) { |
||
157 | return; |
||
158 | } |
||
159 | } |
||
160 | } else { |
||
161 | if (count($firstUriPartExploded) !== count($dimensionPresets)) { |
||
162 | $this->appendDefaultDimensionPresetUriSegments($dimensionPresets, $path); |
||
163 | return; |
||
164 | } |
||
165 | foreach ($dimensionPresets as $dimensionName => $dimensionPreset) { |
||
166 | $uriSegment = array_shift($firstUriPartExploded); |
||
167 | $preset = $this->contentDimensionPresetSource->findPresetByUriSegment($dimensionName, $uriSegment); |
||
168 | if ($preset === null) { |
||
169 | $this->appendDefaultDimensionPresetUriSegments($dimensionPresets, $path); |
||
170 | return; |
||
171 | } |
||
172 | } |
||
173 | } |
||
174 | |||
175 | $path = $matches['firstUriPart'] . '/' . $path; |
||
176 | } |
||
177 | |||
191 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.