| Conditions | 13 | 
| Paths | 18 | 
| Total Lines | 49 | 
| Lines | 20 | 
| Ratio | 40.82 % | 
| 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 // phpcs:ignore WordPress.Files.FileName  | 
            ||
| 57 | 	public function processClassmap( $autoloads, $scanPsrPackages ) { | 
            ||
| 58 | // We can't scan PSR packages if we don't actually have any.  | 
            ||
| 59 | 		if ( empty( $autoloads['psr-4'] ) ) { | 
            ||
| 60 | $scanPsrPackages = false;  | 
            ||
| 61 | }  | 
            ||
| 62 | |||
| 63 | 		if ( empty( $autoloads['classmap'] ) && ! $scanPsrPackages ) { | 
            ||
| 64 | return null;  | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 | $excludedClasses = null;  | 
            ||
| 68 | 		if ( ! empty( $autoloads['exclude-from-classmap'] ) ) { | 
            ||
| 69 | 			$excludedClasses = '{(' . implode( '|', $autoloads['exclude-from-classmap'] ) . ')}'; | 
            ||
| 70 | }  | 
            ||
| 71 | |||
| 72 | $processed = array();  | 
            ||
| 73 | |||
| 74 | 		if ( $scanPsrPackages ) { | 
            ||
| 75 | 			foreach ( $autoloads['psr-4'] as $namespace => $sources ) { | 
            ||
| 76 | $namespace = empty( $namespace ) ? null : $namespace;  | 
            ||
| 77 | |||
| 78 | View Code Duplication | 				foreach ( $sources as $source ) { | 
            |
| 79 | $classmap = call_user_func( $this->classmapScanner, $source['path'], $excludedClasses, $namespace );  | 
            ||
| 80 | |||
| 81 | 					foreach ( $classmap as $class => $path ) { | 
            ||
| 82 | $processed[ $class ] = array(  | 
            ||
| 83 | 'version' => $source['version'],  | 
            ||
| 84 | 'path' => call_user_func( $this->pathCodeTransformer, $path ),  | 
            ||
| 85 | );  | 
            ||
| 86 | }  | 
            ||
| 87 | }  | 
            ||
| 88 | }  | 
            ||
| 89 | }  | 
            ||
| 90 | |||
| 91 | 		if ( ! empty( $autoloads['classmap'] ) ) { | 
            ||
| 92 | View Code Duplication | 			foreach ( $autoloads['classmap'] as $package ) { | 
            |
| 93 | $classmap = call_user_func( $this->classmapScanner, $package['path'], $excludedClasses, null );  | 
            ||
| 94 | |||
| 95 | 				foreach ( $classmap as $class => $path ) { | 
            ||
| 96 | $processed[ $class ] = array(  | 
            ||
| 97 | 'version' => $package['version'],  | 
            ||
| 98 | 'path' => call_user_func( $this->pathCodeTransformer, $path ),  | 
            ||
| 99 | );  | 
            ||
| 100 | }  | 
            ||
| 101 | }  | 
            ||
| 102 | }  | 
            ||
| 103 | |||
| 104 | return $processed;  | 
            ||
| 105 | }  | 
            ||
| 106 | |||
| 163 | 
It seems like you are relying on a variable being defined by an iteration: