| Conditions | 18 | 
| Paths | 34 | 
| Total Lines | 69 | 
| Lines | 31 | 
| Ratio | 44.93 % | 
| 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 | View Code Duplication | 		if ( $scanPsrPackages ) { | 
            |
| 75 | 			foreach ( $autoloads['psr-4'] as $namespace => $sources ) { | 
            ||
| 76 | $namespace = empty( $namespace ) ? null : $namespace;  | 
            ||
| 77 | |||
| 78 | 				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 | /*  | 
            ||
| 92 | * PSR-0 namespaces are converted to classmaps for both optimized and unoptimized autoloaders because any new  | 
            ||
| 93 | * development should use classmap or PSR-4 autoloading.  | 
            ||
| 94 | */  | 
            ||
| 95 | View Code Duplication | 		if ( ! empty( $autoloads['psr-0'] ) ) { | 
            |
| 96 | 			foreach ( $autoloads['psr-0'] as $namespace => $sources ) { | 
            ||
| 97 | $namespace = empty( $namespace ) ? null : $namespace;  | 
            ||
| 98 | |||
| 99 | 				foreach ( $sources as $source ) { | 
            ||
| 100 | $classmap = call_user_func( $this->classmapScanner, $source['path'], $excludedClasses, $namespace );  | 
            ||
| 101 | 					foreach ( $classmap as $class => $path ) { | 
            ||
| 102 | $processed[ $class ] = array(  | 
            ||
| 103 | 'version' => $source['version'],  | 
            ||
| 104 | 'path' => call_user_func( $this->pathCodeTransformer, $path ),  | 
            ||
| 105 | );  | 
            ||
| 106 | }  | 
            ||
| 107 | }  | 
            ||
| 108 | }  | 
            ||
| 109 | }  | 
            ||
| 110 | |||
| 111 | 		if ( ! empty( $autoloads['classmap'] ) ) { | 
            ||
| 112 | 			foreach ( $autoloads['classmap'] as $package ) { | 
            ||
| 113 | $classmap = call_user_func( $this->classmapScanner, $package['path'], $excludedClasses, null );  | 
            ||
| 114 | |||
| 115 | 				foreach ( $classmap as $class => $path ) { | 
            ||
| 116 | $processed[ $class ] = array(  | 
            ||
| 117 | 'version' => $package['version'],  | 
            ||
| 118 | 'path' => call_user_func( $this->pathCodeTransformer, $path ),  | 
            ||
| 119 | );  | 
            ||
| 120 | }  | 
            ||
| 121 | }  | 
            ||
| 122 | }  | 
            ||
| 123 | |||
| 124 | return $processed;  | 
            ||
| 125 | }  | 
            ||
| 126 | |||
| 183 | 
It seems like you are relying on a variable being defined by an iteration: