| Conditions | 11 | 
| Paths | 25 | 
| Total Lines | 62 | 
| Code Lines | 47 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| Bugs | 0 | Features | 2 | 
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  | 
            ||
| 75 | 	public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 76 | $auth = $storage->getAuthMechanism();  | 
            ||
| 77 | 		if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) { | 
            ||
| 78 | 			if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) { | 
            ||
| 79 | 				throw new \InvalidArgumentException('user or password is not set'); | 
            ||
| 80 | }  | 
            ||
| 81 | |||
| 82 | $smbAuth = new BasicAuth(  | 
            ||
| 83 | 				$storage->getBackendOption('user'), | 
            ||
| 84 | 				$storage->getBackendOption('domain'), | 
            ||
| 85 | 				$storage->getBackendOption('password') | 
            ||
| 86 | );  | 
            ||
| 87 | 		} else { | 
            ||
| 88 | 			switch ($auth->getIdentifier()) { | 
            ||
| 89 | case 'smb::kerberos':  | 
            ||
| 90 | $smbAuth = new KerberosAuth();  | 
            ||
| 91 | break;  | 
            ||
| 92 | case 'smb::kerberosapache':  | 
            ||
| 93 | 					if (!$auth instanceof KerberosApacheAuthMechanism) { | 
            ||
| 94 | 						throw new \InvalidArgumentException('invalid authentication backend'); | 
            ||
| 95 | }  | 
            ||
| 96 | $credentialsStore = $auth->getCredentialsStore();  | 
            ||
| 97 | $kerbAuth = new KerberosApacheAuth();  | 
            ||
| 98 | // check if a kerberos ticket is available, else fallback to session credentials  | 
            ||
| 99 | 					if ($kerbAuth->checkTicket()) { | 
            ||
| 100 | $smbAuth = $kerbAuth;  | 
            ||
| 101 | 					} else { | 
            ||
| 102 | 						try { | 
            ||
| 103 | $credentials = $credentialsStore->getLoginCredentials();  | 
            ||
| 104 | $user = $credentials->getLoginName();  | 
            ||
| 105 | $pass = $credentials->getPassword();  | 
            ||
| 106 | 							preg_match('/(.*)@(.*)/', $user, $matches); | 
            ||
| 107 | 							$realm = $storage->getBackendOption('default_realm'); | 
            ||
| 108 | 							if (empty($realm)) { | 
            ||
| 109 | $realm = 'WORKGROUP';  | 
            ||
| 110 | }  | 
            ||
| 111 | $userPart = $matches[1];  | 
            ||
| 112 | $domainPart = $matches[2];  | 
            ||
| 113 | 							if (count($matches) === 0) { | 
            ||
| 114 | $username = $user;  | 
            ||
| 115 | $workgroup = $realm;  | 
            ||
| 116 | 							} else { | 
            ||
| 117 | $username = $userPart;  | 
            ||
| 118 | $workgroup = $domainPart;  | 
            ||
| 119 | }  | 
            ||
| 120 | $smbAuth = new BasicAuth(  | 
            ||
| 121 | $username,  | 
            ||
| 122 | $workgroup,  | 
            ||
| 123 | $pass  | 
            ||
| 124 | );  | 
            ||
| 125 | 						} catch (\Exception $e) { | 
            ||
| 126 | 							throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved'); | 
            ||
| 127 | }  | 
            ||
| 128 | }  | 
            ||
| 129 | |||
| 130 | break;  | 
            ||
| 131 | default:  | 
            ||
| 132 | 					throw new \InvalidArgumentException('unknown authentication backend'); | 
            ||
| 133 | }  | 
            ||
| 134 | }  | 
            ||
| 135 | |||
| 136 | 		$storage->setBackendOption('auth', $smbAuth); | 
            ||
| 137 | }  | 
            ||
| 139 | 
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.