Conditions | 1 |
Paths | 1 |
Total Lines | 74 |
Code Lines | 69 |
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 |
||
42 | public function getNodeDefinition(NodeDefinition $node) |
||
43 | { |
||
44 | $node->children() |
||
45 | ->arrayNode($this->name()) |
||
46 | ->addDefaultsIfNotSet() |
||
47 | ->validate() |
||
48 | ->ifTrue(function ($config) { |
||
49 | return empty($config['default_signature_algorithm']); |
||
50 | }) |
||
51 | ->thenInvalid('The option "default_signature_algorithm" must be set.') |
||
52 | ->end() |
||
53 | ->validate() |
||
54 | ->ifTrue(function ($config) { |
||
55 | return empty($config['signature_algorithms']); |
||
56 | }) |
||
57 | ->thenInvalid('The option "signature_algorithm" must contain at least one signature algorithm.') |
||
58 | ->end() |
||
59 | ->validate() |
||
60 | ->ifTrue(function ($config) { |
||
61 | return !in_array($config['default_signature_algorithm'], $config['signature_algorithms']); |
||
62 | }) |
||
63 | ->thenInvalid('The default signature algorithm must be in the supported signature algorithms.') |
||
64 | ->end() |
||
65 | ->children() |
||
66 | ->scalarNode('default_signature_algorithm') |
||
67 | ->info('Signature algorithm used if the client has not defined a preferred one. Recommended value is "RS256".') |
||
68 | ->end() |
||
69 | ->arrayNode('signature_algorithms') |
||
70 | ->info('Signature algorithm used to sign the ID Tokens.') |
||
71 | ->useAttributeAsKey('name') |
||
72 | ->prototype('scalar')->end() |
||
73 | ->treatNullLike([]) |
||
74 | ->treatFalseLike([]) |
||
75 | ->end() |
||
76 | ->arrayNode('claim_checkers') |
||
77 | ->info('Checkers will verify the JWT claims.') |
||
78 | ->useAttributeAsKey('name') |
||
79 | ->prototype('scalar')->end() |
||
80 | ->treatNullLike(['exp', 'iat', 'nbf']) |
||
81 | ->end() |
||
82 | ->arrayNode('header_checkers') |
||
83 | ->info('Checkers will verify the JWT headers.') |
||
84 | ->useAttributeAsKey('name') |
||
85 | ->prototype('scalar')->end() |
||
86 | ->treatNullLike([]) |
||
87 | ->treatFalseLike([]) |
||
88 | ->end() |
||
89 | ->integerNode('lifetime') |
||
90 | ->info('Lifetime of the ID Tokens (in seconds). If an access token is issued with the ID Token, the lifetime of the access token is used instead of this value.') |
||
91 | ->defaultValue(3600) |
||
92 | ->min(1) |
||
93 | ->end() |
||
94 | ->arrayNode('encryption') |
||
95 | ->canBeEnabled() |
||
96 | ->children() |
||
97 | ->arrayNode('key_encryption_algorithms') |
||
98 | ->info('Supported key encryption algorithms.') |
||
99 | ->useAttributeAsKey('name') |
||
100 | ->prototype('scalar')->end() |
||
101 | ->treatNullLike([]) |
||
102 | ->treatFalseLike([]) |
||
103 | ->end() |
||
104 | ->arrayNode('content_encryption_algorithms') |
||
105 | ->info('Supported content encryption algorithms.') |
||
106 | ->useAttributeAsKey('name') |
||
107 | ->prototype('scalar')->end() |
||
108 | ->treatNullLike([]) |
||
109 | ->treatFalseLike([]) |
||
110 | ->end() |
||
111 | ->end() |
||
112 | ->end() |
||
113 | ->end() |
||
114 | ->end(); |
||
115 | } |
||
116 | |||
135 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.