| Conditions | 3 |
| Paths | 1 |
| Total Lines | 95 |
| Code Lines | 90 |
| 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 |
||
| 79 | public function getNodeDefinition(NodeDefinition $node) |
||
| 80 | { |
||
| 81 | $node->children() |
||
| 82 | ->arrayNode($this->name()) |
||
| 83 | ->addDefaultsIfNotSet() |
||
| 84 | ->children() |
||
| 85 | ->arrayNode('authorization_code') |
||
| 86 | ->validate() |
||
| 87 | ->ifTrue(function ($config) { |
||
| 88 | return $config['max_length'] < $config['min_length']; |
||
| 89 | }) |
||
| 90 | ->thenInvalid('The option "max_length" must be greater than "min_length".') |
||
| 91 | ->end() |
||
| 92 | ->canBeEnabled() |
||
| 93 | ->children() |
||
| 94 | ->integerNode('min_length') |
||
| 95 | ->defaultValue(50) |
||
| 96 | ->min(0) |
||
| 97 | ->info('Minimum length of the randomly generated authorization code') |
||
| 98 | ->end() |
||
| 99 | ->integerNode('max_length') |
||
| 100 | ->defaultValue(100) |
||
| 101 | ->min(1) |
||
| 102 | ->info('Maximum length of the randomly generated authorization code') |
||
| 103 | ->end() |
||
| 104 | ->integerNode('lifetime') |
||
| 105 | ->defaultValue(30) |
||
| 106 | ->min(1) |
||
| 107 | ->info('Authorization code lifetime (in seconds)') |
||
| 108 | ->end() |
||
| 109 | ->scalarNode('repository') |
||
| 110 | ->isRequired() |
||
| 111 | ->info('The authorization code repository') |
||
| 112 | ->end() |
||
| 113 | ->booleanNode('enforce_pkce') |
||
| 114 | ->defaultFalse() |
||
| 115 | ->info('If true, the PKCE is required for all requests including the ones from confidential clients') |
||
| 116 | ->end() |
||
| 117 | ->end() |
||
| 118 | ->end() |
||
| 119 | ->arrayNode('client_credentials') |
||
| 120 | ->canBeEnabled() |
||
| 121 | ->children() |
||
| 122 | ->booleanNode('issue_refresh_token') |
||
| 123 | ->info('If enabled, a refresh token will be issued with an access token (not recommended)') |
||
| 124 | ->defaultFalse() |
||
| 125 | ->end() |
||
| 126 | ->end() |
||
| 127 | ->end() |
||
| 128 | ->arrayNode('resource_owner_password_credential') |
||
| 129 | ->canBeEnabled() |
||
| 130 | ->end() |
||
| 131 | ->arrayNode('implicit') |
||
| 132 | ->canBeEnabled() |
||
| 133 | ->end() |
||
| 134 | ->arrayNode('refresh_token') |
||
| 135 | ->canBeEnabled() |
||
| 136 | ->validate() |
||
| 137 | ->ifTrue(function ($config) { |
||
| 138 | return true === $config['enabled'] && empty($config['repository']); |
||
| 139 | }) |
||
| 140 | ->thenInvalid('The option "repository" must be set.') |
||
| 141 | ->end() |
||
| 142 | ->validate() |
||
| 143 | ->ifTrue(function ($config) { |
||
| 144 | return true === $config['enabled'] && $config['max_length'] < $config['min_length']; |
||
| 145 | }) |
||
| 146 | ->thenInvalid('The option "max_length" must be greater than "min_length".') |
||
| 147 | ->end() |
||
| 148 | ->children() |
||
| 149 | ->integerNode('min_length') |
||
| 150 | ->defaultValue(50) |
||
| 151 | ->min(0) |
||
| 152 | ->info('Minimum length of the randomly generated refresh tokens') |
||
| 153 | ->end() |
||
| 154 | ->integerNode('max_length') |
||
| 155 | ->defaultValue(100) |
||
| 156 | ->min(1) |
||
| 157 | ->info('Maximum length of the randomly generated refresh tokens') |
||
| 158 | ->end() |
||
| 159 | ->integerNode('lifetime') |
||
| 160 | ->defaultValue(60 * 60 * 24 * 7) |
||
| 161 | ->min(1) |
||
| 162 | ->info('The refresh token lifetime (in seconds)') |
||
| 163 | ->end() |
||
| 164 | ->scalarNode('repository') |
||
| 165 | ->defaultNull() |
||
| 166 | ->info('The refresh token repository') |
||
| 167 | ->end() |
||
| 168 | ->end() |
||
| 169 | ->end() |
||
| 170 | ->end() |
||
| 171 | ->end() |
||
| 172 | ->end(); |
||
| 173 | } |
||
| 174 | |||
| 184 |