| Conditions | 15 |
| Paths | 9 |
| Total Lines | 50 |
| Code Lines | 28 |
| 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 |
||
| 78 | } |
||
| 79 | |||
| 80 | $pList = explode(',', $proxies); |
||
| 81 | $resultList = []; |
||
| 82 | foreach ($pList as $proxy) { |
||
| 83 | $resultList[] = trim($proxy); |
||
| 84 | } |
||
| 85 | self::setTrustedProxies($resultList); |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Get pathway as string |
||
| 90 | * @return string |
||
| 91 | */ |
||
| 92 | public function getPathInfo() |
||
| 93 | { |
||
| 94 | $route = $this->languageInPath ? Str::sub(parent::getPathInfo(), Str::length($this->language) + 1) : parent::getPathInfo(); |
||
| 95 | if (!Str::startsWith('/', $route)) { |
||
| 96 | $route = '/' . $route; |
||
| 97 | } |
||
| 98 | return $route; |
||
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Get pathway without current controller/action path |
||
| 103 | * @return string |
||
| 104 | */ |
||
| 105 | public function getPathWithoutControllerAction(): ?string |
||
| 106 | { |
||
| 107 | $path = trim($this->getPathInfo(), '/'); |
||
| 108 | if ($this->aliasPathTarget !== null) { |
||
| 109 | $path = trim($this->aliasPathTarget, '/'); |
||
| 110 | } |
||
| 111 | |||
| 112 | $pathArray = explode('/', $path); |
||
| 113 | if ($pathArray[0] === Str::lowerCase($this->getController())) { |
||
| 114 | // unset controller |
||
| 115 | array_shift($pathArray); |
||
| 116 | if ($pathArray[0] === Str::lowerCase($this->getAction())) { |
||
| 117 | // unset action |
||
| 118 | array_shift($pathArray); |
||
| 119 | } |
||
| 120 | } |
||
| 121 | return trim(implode('/', $pathArray), '/'); |
||
| 122 | } |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Get current full request URI |
||
| 126 | * @return string |
||
| 127 | */ |
||
| 128 | public function getFullUrl(): string |
||
| 148 |