| 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 | ||
| 53 | private function addExceptionsSection(ArrayNodeDefinition $rootNode): void | ||
| 54 |     { | ||
| 55 | $rootNode->children() | ||
| 56 |             ->arrayNode('exception_handling') | ||
| 57 | ->treatTrueLike(['enabled' => true]) | ||
| 58 | ->treatFalseLike(['enabled' => false]) | ||
| 59 | ->treatNullLike(['enabled' => null]) | ||
| 60 | ->addDefaultsIfNotSet() | ||
| 61 | ->children() | ||
| 62 |                     ->booleanNode('enabled') | ||
| 63 | ->info( | ||
| 64 | 'Set to true to enable the new serialization-based exception handling.'.PHP_EOL. | ||
| 65 | 'Set to false to disable exception handling provided by this bundle.'.PHP_EOL. | ||
| 66 | 'Set to null to keep using the deprecated exception JSON response builder.' | ||
| 67 | ) | ||
| 68 | ->defaultNull() | ||
| 69 | ->validate() | ||
| 70 | ->ifNull() | ||
| 71 |                             ->then(function ($value) { | ||
| 72 | trigger_deprecation( | ||
| 73 | self::BUNDLE_NAME, | ||
| 74 | '1.3', | ||
| 75 | 'Setting the "nijens_openapi.exceptions.enabled" option to "null" is deprecated. It will default to "true" as of version 2.0.' | ||
| 76 | ); | ||
| 77 | |||
| 78 | return $value; | ||
| 79 | }) | ||
| 80 | ->end() | ||
| 81 | ->end() | ||
| 82 |                     ->arrayNode('exceptions') | ||
| 83 |                         ->useAttributeAsKey('class') | ||
| 84 | ->arrayPrototype() | ||
| 85 | ->children() | ||
| 86 |                                 ->scalarNode('class') | ||
| 87 |                                     ->info('The fully qualified class name of the exception.') | ||
| 88 | ->cannotBeEmpty() | ||
| 89 | ->end() | ||
| 90 |                                 ->integerNode('status_code') | ||
| 91 |                                     ->info('The HTTP status code that must be sent when this exception occurs.') | ||
| 92 | ->isRequired() | ||
| 93 | ->min(100) | ||
| 94 | ->max(999) | ||
| 95 | ->end() | ||
| 96 |                                 ->scalarNode('type_uri') | ||
| 97 |                                     ->info('The RFC 7807 URI reference that identifies the problem type. It will be sent with the response.') | ||
| 98 | ->cannotBeEmpty() | ||
| 99 |                                     ->defaultValue('about:blank') | ||
| 100 | ->end() | ||
| 101 |                                 ->scalarNode('title') | ||
| 102 |                                     ->info('The RFC 7807 title that summarizes the problem type in human-readable language. It will be sent with the response.') | ||
| 103 | ->cannotBeEmpty() | ||
| 104 |                                     ->defaultValue('An error occurred.') | ||
| 105 | ->end() | ||
| 106 |                                 ->booleanNode('add_instance_uri') | ||
| 107 | ->defaultFalse() | ||
| 108 | ->end() | ||
| 109 | ->end() | ||
| 110 | ->end() | ||
| 111 | ->end() | ||
| 112 | ->end() | ||
| 113 | ->end() | ||
| 114 | ->end(); | ||
| 115 | } | ||
| 117 |