Conditions | 1 |
Paths | 1 |
Total Lines | 62 |
Code Lines | 56 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
108 | private function addExceptionsSection(ArrayNodeDefinition $rootNode): void |
||
109 | { |
||
110 | $rootNode->children() |
||
111 | ->arrayNode('exception_handling') |
||
112 | ->treatTrueLike(['enabled' => true]) |
||
113 | ->treatFalseLike(['enabled' => false]) |
||
114 | ->treatNullLike(['enabled' => null]) |
||
115 | ->addDefaultsIfNotSet() |
||
116 | ->children() |
||
117 | ->booleanNode('enabled') |
||
118 | ->info( |
||
119 | 'Set to true to enable the new serialization-based exception handling.'.PHP_EOL. |
||
120 | 'Set to false to disable exception handling provided by this bundle.'.PHP_EOL. |
||
121 | 'Set to null to keep using the deprecated exception JSON response builder.' |
||
122 | ) |
||
123 | ->defaultNull() |
||
124 | ->validate() |
||
125 | ->ifNull() |
||
126 | ->then(function ($value) { |
||
127 | trigger_deprecation( |
||
128 | self::BUNDLE_NAME, |
||
129 | '1.3', |
||
130 | 'Setting the "nijens_openapi.exceptions.enabled" option to "null" is deprecated. It will default to "true" as of version 2.0.' |
||
131 | ); |
||
132 | |||
133 | return $value; |
||
134 | }) |
||
135 | ->end() |
||
136 | ->end() |
||
137 | ->arrayNode('exceptions') |
||
138 | ->useAttributeAsKey('class') |
||
139 | ->arrayPrototype() |
||
140 | ->children() |
||
141 | ->scalarNode('class') |
||
142 | ->info('The fully qualified class name of the exception.') |
||
143 | ->cannotBeEmpty() |
||
144 | ->end() |
||
145 | ->integerNode('status_code') |
||
146 | ->info('The HTTP status code that must be sent when this exception occurs.') |
||
147 | ->isRequired() |
||
148 | ->min(100) |
||
149 | ->max(999) |
||
150 | ->end() |
||
151 | ->scalarNode('type_uri') |
||
152 | ->info('The RFC 7807 URI reference that identifies the problem type. It will be sent with the response.') |
||
153 | ->cannotBeEmpty() |
||
154 | ->defaultValue('about:blank') |
||
155 | ->end() |
||
156 | ->scalarNode('title') |
||
157 | ->info('The RFC 7807 title that summarizes the problem type in human-readable language. It will be sent with the response.') |
||
158 | ->cannotBeEmpty() |
||
159 | ->defaultValue('An error occurred.') |
||
160 | ->end() |
||
161 | ->booleanNode('add_instance_uri') |
||
162 | ->defaultFalse() |
||
163 | ->end() |
||
164 | ->end() |
||
165 | ->end() |
||
166 | ->end() |
||
167 | ->end() |
||
168 | ->end() |
||
169 | ->end(); |
||
170 | } |
||
172 |