| Conditions | 17 |
| Paths | 122 |
| Total Lines | 78 |
| Code Lines | 37 |
| 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 |
||
| 163 | public static function get($ds, $host, $version=3) |
||
| 164 | { |
||
| 165 | $filter='(objectclass=*)'; |
||
| 166 | $justthese = array('structuralObjectClass','namingContexts','supportedLDAPVersion','subschemaSubentry','vendorname'); |
||
| 167 | if(($sr = @ldap_read($ds, '', $filter, $justthese))) |
||
| 168 | { |
||
| 169 | if(($info = ldap_get_entries($ds, $sr))) |
||
| 170 | { |
||
| 171 | $ldapServerInfo = new ServerInfo($host); |
||
| 172 | $ldapServerInfo->setVersion($version); |
||
| 173 | |||
| 174 | // check for naming contexts |
||
| 175 | if($info[0]['namingcontexts']) |
||
| 176 | { |
||
| 177 | for($i=0; $i<$info[0]['namingcontexts']['count']; $i++) |
||
| 178 | { |
||
| 179 | $namingcontexts[] = $info[0]['namingcontexts'][$i]; |
||
| 180 | } |
||
| 181 | $ldapServerInfo->setNamingContexts($namingcontexts); |
||
| 182 | } |
||
| 183 | |||
| 184 | // check for ldap server type |
||
| 185 | if($info[0]['structuralobjectclass']) |
||
| 186 | { |
||
| 187 | switch($info[0]['structuralobjectclass'][0]) |
||
| 188 | { |
||
| 189 | case 'OpenLDAProotDSE': |
||
| 190 | $ldapServerType = self::OPENLDAP; |
||
| 191 | break; |
||
| 192 | default: |
||
| 193 | $ldapServerType = self::UNKNOWN; |
||
| 194 | break; |
||
| 195 | } |
||
| 196 | $ldapServerInfo->setServerType($ldapServerType); |
||
| 197 | } |
||
| 198 | if ($info[0]['vendorname'] && stripos($info[0]['vendorname'][0], 'samba') !== false) |
||
| 199 | { |
||
| 200 | $ldapServerInfo->setServerType(self::SAMBA4); |
||
| 201 | } |
||
| 202 | |||
| 203 | // check for subschema entry dn |
||
| 204 | if($info[0]['subschemasubentry']) |
||
| 205 | { |
||
| 206 | $subschemasubentry = $info[0]['subschemasubentry'][0]; |
||
| 207 | $ldapServerInfo->setSubSchemaEntry($subschemasubentry); |
||
| 208 | } |
||
| 209 | |||
| 210 | // create list of supported objetclasses |
||
| 211 | if(!empty($subschemasubentry)) |
||
| 212 | { |
||
| 213 | $filter='(objectclass=*)'; |
||
| 214 | $justthese = array('objectClasses'); |
||
| 215 | |||
| 216 | if(($sr = ldap_read($ds, $subschemasubentry, $filter, $justthese))) |
||
| 217 | { |
||
| 218 | if(($info = ldap_get_entries($ds, $sr))) |
||
| 219 | { |
||
| 220 | if($info[0]['objectclasses']) { |
||
| 221 | for($i=0; $i<$info[0]['objectclasses']['count']; $i++) |
||
| 222 | { |
||
| 223 | $matches = null; |
||
| 224 | if(preg_match('/^\( (.*) NAME \'(\w*)\' /', $info[0]['objectclasses'][$i], $matches)) |
||
| 225 | { |
||
| 226 | #_debug_array($matches); |
||
| 227 | if(count($matches) == 3) |
||
| 228 | { |
||
| 229 | $supportedObjectClasses[$matches[1]] = strtolower($matches[2]); |
||
| 230 | } |
||
| 231 | } |
||
| 232 | } |
||
| 233 | $ldapServerInfo->setSupportedObjectClasses($supportedObjectClasses); |
||
| 234 | } |
||
| 235 | } |
||
| 236 | } |
||
| 237 | } |
||
| 238 | } |
||
| 239 | } |
||
| 240 | return $ldapServerInfo; |
||
| 241 | } |
||
| 243 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths