| Conditions | 4 |
| Paths | 8 |
| Total Lines | 56 |
| Code Lines | 40 |
| 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 |
||
| 110 | protected function setSecurityConfiguration(ContainerBuilder $container, array $config) |
||
| 111 | { |
||
| 112 | $roles = isset($config['roles']) ? $config['roles'] : []; |
||
| 113 | $additionalAttributes = isset($config['additional_attributes']) ? $config['additional_attributes'] : []; |
||
| 114 | |||
| 115 | $container->setParameter('ldap_tools.security.additional_attributes', $additionalAttributes); |
||
| 116 | $container->setParameter('ldap_tools.security.check_groups_recursively', $config['check_groups_recursively']); |
||
| 117 | $container->setParameter('ldap_tools.security.user', $config['user']); |
||
| 118 | $container->setParameter('ldap_tools.security.roles', $roles); |
||
| 119 | $container->setParameter('ldap_tools.security.default_role', $config['default_role']); |
||
| 120 | $container->setParameter('ldap_tools.security.guard.auth_success', [ |
||
| 121 | 'default_target_path' => $config['guard']['default_target_path'], |
||
| 122 | 'always_use_target_path' => $config['guard']['always_use_target_path'], |
||
| 123 | 'target_path_parameter' => $config['guard']['target_path_parameter'], |
||
| 124 | 'use_referrer' => $config['guard']['use_referrer'], |
||
| 125 | ]); |
||
| 126 | $container->setParameter('ldap_tools.security.guard.auth_failure', [ |
||
| 127 | 'failure_path' => $config['guard']['failure_path'], |
||
| 128 | 'failure_forward' => $config['guard']['failure_forward'], |
||
| 129 | 'failure_path_parameter' => $config['guard']['failure_path_parameter'], |
||
| 130 | ]); |
||
| 131 | |||
| 132 | $container->getDefinition('ldap_tools.security.user.ldap_user_provider')->addMethodCall( |
||
| 133 | 'setLdapObjectType', |
||
| 134 | [$config['ldap_object_type']] |
||
| 135 | ); |
||
| 136 | |||
| 137 | $container->getDefinition('ldap_tools.security.ldap_guard_authenticator')->addMethodCall( |
||
| 138 | 'setStartPath', |
||
| 139 | [$config['guard']['start_path']] |
||
| 140 | ); |
||
| 141 | |||
| 142 | $userProviderDef = $container->getDefinition('ldap_tools.security.user.ldap_user_provider'); |
||
| 143 | if (isset($config['search_base'])) { |
||
| 144 | $userProviderDef->addMethodCall( |
||
| 145 | 'setSearchBase', |
||
| 146 | [$config['search_base']] |
||
| 147 | ); |
||
| 148 | } |
||
| 149 | $userProviderDef->addMethodCall( |
||
| 150 | 'setRoleLdapType', |
||
| 151 | [$config['role_ldap_type']] |
||
| 152 | ); |
||
| 153 | $userProviderDef->addMethodCall( |
||
| 154 | 'setRoleAttributeMap', |
||
| 155 | [$config['role_attributes']] |
||
| 156 | ); |
||
| 157 | $userProviderDef->addMethodCall( |
||
| 158 | 'setRefreshAttributes', |
||
| 159 | [$config['refresh_user_attributes']] |
||
| 160 | ); |
||
| 161 | $userProviderDef->addMethodCall( |
||
| 162 | 'setRefreshRoles', |
||
| 163 | [$config['refresh_user_roles']] |
||
| 164 | ); |
||
| 165 | } |
||
| 166 | } |
||
| 167 |