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