| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 68 |
| 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 |
||
| 33 | public function getConfigTreeBuilder() |
||
| 34 | { |
||
| 35 | $treeBuilder = new TreeBuilder(); |
||
| 36 | $rootNode = $treeBuilder->root('api_platform'); |
||
| 37 | |||
| 38 | $rootNode |
||
| 39 | ->children() |
||
| 40 | ->scalarNode('title')->defaultValue('')->info('The title of the API.')->end() |
||
| 41 | ->scalarNode('description')->defaultValue('')->info('The description of the API.')->end() |
||
| 42 | ->scalarNode('version')->defaultValue('0.0.0')->info('The version of the API.')->end() |
||
| 43 | ->scalarNode('default_operation_path_resolver')->defaultValue('api_platform.operation_path_resolver.underscore')->info('Specify the default operation path resolver to use for generating resources operations path.')->end() |
||
| 44 | ->scalarNode('name_converter')->defaultNull()->info('Specify a name converter to use.')->end() |
||
| 45 | ->arrayNode('eager_loading') |
||
| 46 | ->canBeDisabled() |
||
| 47 | ->addDefaultsIfNotSet() |
||
| 48 | ->children() |
||
| 49 | ->booleanNode('enabled')->defaultTrue()->info('To enable or disable eager loading')->end() |
||
| 50 | ->integerNode('max_joins')->defaultValue(30)->info('Max number of joined relations before EagerLoading throws a RuntimeException')->end() |
||
| 51 | ->booleanNode('force_eager')->defaultTrue()->info('Force join on every relation. If disabled, it will only join relations having the EAGER fetch mode.')->end() |
||
| 52 | ->end() |
||
| 53 | ->end() |
||
| 54 | ->booleanNode('enable_fos_user')->defaultValue(false)->info('Enable the FOSUserBundle integration.')->end() |
||
| 55 | ->booleanNode('enable_nelmio_api_doc')->defaultValue(false)->info('Enable the Nelmio Api doc integration.')->end() |
||
| 56 | ->booleanNode('enable_swagger')->defaultValue(true)->info('Enable the Swagger documentation and export.')->end() |
||
| 57 | ->booleanNode('enable_swagger_ui')->defaultValue(true)->info('Enable Swagger ui.')->end() |
||
| 58 | |||
| 59 | ->arrayNode('collection') |
||
| 60 | ->addDefaultsIfNotSet() |
||
| 61 | ->children() |
||
| 62 | ->scalarNode('order')->defaultNull()->info('The default order of results.')->end() |
||
| 63 | ->scalarNode('order_parameter_name')->defaultValue('order')->cannotBeEmpty()->info('The name of the query parameter to order results.')->end() |
||
| 64 | ->arrayNode('pagination') |
||
| 65 | ->canBeDisabled() |
||
| 66 | ->addDefaultsIfNotSet() |
||
| 67 | ->children() |
||
| 68 | ->booleanNode('enabled')->defaultTrue()->info('To enable or disable pagination for all resource collections by default.')->end() |
||
| 69 | ->booleanNode('client_enabled')->defaultFalse()->info('To allow the client to enable or disable the pagination.')->end() |
||
| 70 | ->booleanNode('client_items_per_page')->defaultFalse()->info('To allow the client to set the number of items per page.')->end() |
||
| 71 | ->integerNode('items_per_page')->defaultValue(30)->info('The default number of items per page.')->end() |
||
| 72 | ->integerNode('maximum_items_per_page')->defaultNull()->info('The maximum number of items per page.')->end() |
||
| 73 | ->scalarNode('page_parameter_name')->defaultValue('page')->cannotBeEmpty()->info('The default name of the parameter handling the page number.')->end() |
||
| 74 | ->scalarNode('enabled_parameter_name')->defaultValue('pagination')->cannotBeEmpty()->info('The name of the query parameter to enable or disable pagination.')->end() |
||
| 75 | ->scalarNode('items_per_page_parameter_name')->defaultValue('itemsPerPage')->cannotBeEmpty()->info('The name of the query parameter to set the number of items per page.')->end() |
||
| 76 | ->end() |
||
| 77 | ->end() |
||
| 78 | ->end() |
||
| 79 | ->end() |
||
| 80 | |||
| 81 | ->arrayNode('loader_paths') |
||
| 82 | ->addDefaultsIfNotSet() |
||
| 83 | ->children() |
||
| 84 | ->arrayNode('annotation') |
||
| 85 | ->prototype('scalar')->end() |
||
| 86 | ->end() |
||
| 87 | ->arrayNode('yaml') |
||
| 88 | ->prototype('scalar')->end() |
||
| 89 | ->end() |
||
| 90 | ->arrayNode('xml') |
||
| 91 | ->prototype('scalar')->end() |
||
| 92 | ->end() |
||
| 93 | ->end() |
||
| 94 | ->end() |
||
| 95 | ->end(); |
||
| 96 | |||
| 97 | $this->addExceptionToStatusSection($rootNode); |
||
| 98 | |||
| 99 | $this->addFormatSection($rootNode, 'formats', [ |
||
| 100 | 'jsonld' => ['mime_types' => ['application/ld+json']], |
||
| 101 | 'json' => ['mime_types' => ['application/json']], // Swagger support |
||
| 102 | 'html' => ['mime_types' => ['text/html']], // Swagger UI support |
||
| 103 | ]); |
||
| 104 | $this->addFormatSection($rootNode, 'error_formats', [ |
||
| 105 | 'jsonproblem' => ['mime_types' => ['application/problem+json']], |
||
| 106 | 'jsonld' => ['mime_types' => ['application/ld+json']], |
||
| 107 | ]); |
||
| 108 | |||
| 109 | return $treeBuilder; |
||
| 110 | } |
||
| 111 | |||
| 203 |