| Conditions | 13 |
| Paths | 432 |
| Total Lines | 48 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 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 |
||
| 58 | public function transform( string $target = null, string $controller = null, string $action = null, |
||
| 59 | array $params = [], array $trailing = [], array $config = [] ) : string |
||
| 60 | { |
||
| 61 | $locale = $this->getValue( $params, 'locale' ); |
||
| 62 | |||
| 63 | if( (bool) $this->getValue( $config, 'BE', false ) === false ) { |
||
| 64 | $params['controller'] = $controller !== null ? ucfirst( $controller ) : null; |
||
| 65 | $params['action'] = $action; |
||
| 66 | } |
||
| 67 | |||
| 68 | if( $this->prefix != '' && (bool) $this->getValue( $config, 'namespace', true ) === true ) { |
||
| 69 | $params = [$this->prefix => $params]; |
||
| 70 | } |
||
| 71 | $params += $this->fixed; |
||
| 72 | |||
| 73 | if( (bool) $this->getValue( $config, 'BE', false ) === true ) { |
||
| 74 | $params['controller'] = $controller !== null ? ucfirst( $controller ) : null; |
||
| 75 | $params['action'] = $action; |
||
| 76 | } |
||
| 77 | |||
| 78 | if( ( $eid = $this->getValue( $config, 'eID' ) ) !== null ) { |
||
| 79 | $params['eID'] = $eid; |
||
| 80 | } |
||
| 81 | |||
| 82 | if( $locale !== null && (bool) $this->getValue( $config, 'BE', false ) === false ) { |
||
| 83 | $params['L'] = $locale; |
||
| 84 | } |
||
| 85 | |||
| 86 | $useCHash = (bool) $this->getValue( $config, 'chash', false ); |
||
| 87 | |||
| 88 | $this->uriBuilder->reset() |
||
| 89 | ->setCreateAbsoluteUri( (bool) $this->getValue( $config, 'absoluteUri', false ) ) |
||
| 90 | ->setTargetPageType( (int) $this->getValue( $config, 'type', 0 ) ) |
||
| 91 | ->setNoCache( (bool) $this->getValue( $config, 'nocache', false ) ) |
||
| 92 | ->setFormat( (string) $this->getValue( $config, 'format', '' ) ) |
||
| 93 | ->setArguments( $this->sanitize( $params ) ) |
||
| 94 | ->setSection( join( '/', $trailing ) ); |
||
| 95 | |||
| 96 | if( $target ) { |
||
| 97 | $this->uriBuilder->setTargetPageUid( (int) $target ); |
||
| 98 | } |
||
| 99 | |||
| 100 | if( (bool) $this->getValue( $config, 'BE', false ) === true ) { |
||
| 101 | return (string) $this->uriBuilder->buildBackendUri(); |
||
| 102 | } |
||
| 103 | |||
| 104 | $url = (string) $this->uriBuilder->buildFrontendUri(); |
||
| 105 | return $useCHash ? $url : preg_replace( '/\&cHash=[0-9a-f]{32}/', '', $url ); // wokaround for bad TYPO3 behavior |
||
| 106 | } |
||
| 126 |