Conditions | 2 |
Paths | 2 |
Total Lines | 165 |
Code Lines | 151 |
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 |
||
50 | public function getConfigTreeBuilder() |
||
51 | { |
||
52 | if (method_exists(TreeBuilder::class, 'getRootNode')) { |
||
53 | $treeBuilder = new TreeBuilder('api_platform'); |
||
54 | $rootNode = $treeBuilder->getRootNode(); |
||
55 | } else { |
||
56 | $treeBuilder = new TreeBuilder(); |
||
57 | $rootNode = $treeBuilder->root('api_platform'); |
||
58 | } |
||
59 | |||
60 | $rootNode |
||
61 | ->beforeNormalization() |
||
62 | ->ifTrue(static function ($v) { |
||
63 | return false === ($v['enable_swagger'] ?? null); |
||
64 | }) |
||
65 | ->then(static function ($v) { |
||
66 | $v['swagger']['versions'] = []; |
||
67 | |||
68 | return $v; |
||
69 | }) |
||
70 | ->end() |
||
71 | ->children() |
||
72 | ->scalarNode('title') |
||
73 | ->info('The title of the API.') |
||
74 | ->cannotBeEmpty() |
||
75 | ->defaultValue('') |
||
76 | ->end() |
||
77 | ->scalarNode('description') |
||
78 | ->info('The description of the API.') |
||
79 | ->cannotBeEmpty() |
||
80 | ->defaultValue('') |
||
81 | ->end() |
||
82 | ->scalarNode('version') |
||
83 | ->info('The version of the API.') |
||
84 | ->cannotBeEmpty() |
||
85 | ->defaultValue('0.0.0') |
||
86 | ->end() |
||
87 | ->booleanNode('show_webby')->defaultTrue()->info('If true, show Webby on the documentation page')->end() |
||
88 | ->scalarNode('default_operation_path_resolver') |
||
89 | ->defaultValue('api_platform.operation_path_resolver.underscore') |
||
90 | ->setDeprecated('The use of the `default_operation_path_resolver` has been deprecated in 2.1 and will be removed in 3.0. Use `path_segment_name_generator` instead.') |
||
91 | ->info('Specify the default operation path resolver to use for generating resources operations path.') |
||
92 | ->end() |
||
93 | ->scalarNode('name_converter')->defaultNull()->info('Specify a name converter to use.')->end() |
||
94 | ->scalarNode('path_segment_name_generator')->defaultValue('api_platform.path_segment_name_generator.underscore')->info('Specify a path name generator to use.')->end() |
||
95 | ->booleanNode('allow_plain_identifiers')->defaultFalse()->info('Allow plain identifiers, for example "id" instead of "@id" when denormalizing a relation.')->end() |
||
96 | ->arrayNode('validator') |
||
97 | ->addDefaultsIfNotSet() |
||
98 | ->children() |
||
99 | ->variableNode('serialize_payload_fields')->defaultValue([])->info('Enable the serialization of payload fields when a validation error is thrown.')->end() |
||
100 | ->end() |
||
101 | ->end() |
||
102 | ->arrayNode('eager_loading') |
||
103 | ->canBeDisabled() |
||
104 | ->addDefaultsIfNotSet() |
||
105 | ->children() |
||
106 | ->booleanNode('fetch_partial')->defaultFalse()->info('Fetch only partial data according to serialization groups. If enabled, Doctrine ORM entities will not work as expected if any of the other fields are used.')->end() |
||
107 | ->integerNode('max_joins')->defaultValue(30)->info('Max number of joined relations before EagerLoading throws a RuntimeException')->end() |
||
108 | ->booleanNode('force_eager')->defaultTrue()->info('Force join on every relation. If disabled, it will only join relations having the EAGER fetch mode.')->end() |
||
109 | ->end() |
||
110 | ->end() |
||
111 | ->booleanNode('enable_fos_user')->defaultValue(class_exists(FOSUserBundle::class))->info('Enable the FOSUserBundle integration.')->end() |
||
112 | ->booleanNode('enable_nelmio_api_doc') |
||
113 | ->defaultFalse() |
||
114 | ->setDeprecated('Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.') |
||
115 | ->info('Enable the NelmioApiDocBundle integration.') |
||
116 | ->end() |
||
117 | ->booleanNode('enable_swagger')->defaultTrue()->info('Enable the Swagger documentation and export.')->end() |
||
118 | ->booleanNode('enable_swagger_ui')->defaultValue(class_exists(TwigBundle::class))->info('Enable Swagger UI')->end() |
||
119 | ->booleanNode('enable_re_doc')->defaultValue(class_exists(TwigBundle::class))->info('Enable ReDoc')->end() |
||
120 | ->booleanNode('enable_entrypoint')->defaultTrue()->info('Enable the entrypoint')->end() |
||
121 | ->booleanNode('enable_docs')->defaultTrue()->info('Enable the docs')->end() |
||
122 | ->booleanNode('enable_profiler')->defaultTrue()->info('Enable the data collector and the WebProfilerBundle integration.')->end() |
||
123 | ->arrayNode('collection') |
||
124 | ->addDefaultsIfNotSet() |
||
125 | ->children() |
||
126 | ->scalarNode('exists_parameter_name')->defaultValue('exists')->cannotBeEmpty()->info('The name of the query parameter to filter on nullable field values.')->end() |
||
127 | ->scalarNode('order')->defaultValue('ASC')->info('The default order of results.')->end() // Default ORDER is required for postgresql and mysql >= 5.7 when using LIMIT/OFFSET request |
||
128 | ->scalarNode('order_parameter_name')->defaultValue('order')->cannotBeEmpty()->info('The name of the query parameter to order results.')->end() |
||
129 | ->arrayNode('pagination') |
||
130 | ->canBeDisabled() |
||
131 | ->addDefaultsIfNotSet() |
||
132 | ->children() |
||
133 | ->booleanNode('enabled') |
||
134 | ->setDeprecated('The use of the `collection.pagination.enabled` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_enabled` instead.') |
||
135 | ->defaultTrue() |
||
136 | ->info('To enable or disable pagination for all resource collections by default.') |
||
137 | ->end() |
||
138 | ->booleanNode('partial') |
||
139 | ->setDeprecated('The use of the `collection.pagination.partial` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_partial` instead.') |
||
140 | ->defaultFalse() |
||
141 | ->info('To enable or disable partial pagination for all resource collections by default when pagination is enabled.') |
||
142 | ->end() |
||
143 | ->booleanNode('client_enabled') |
||
144 | ->setDeprecated('The use of the `collection.pagination.client_enabled` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_client_enabled` instead.') |
||
145 | ->defaultFalse() |
||
146 | ->info('To allow the client to enable or disable the pagination.') |
||
147 | ->end() |
||
148 | ->booleanNode('client_items_per_page') |
||
149 | ->setDeprecated('The use of the `collection.pagination.client_items_per_page` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_client_items_per_page` instead.') |
||
150 | ->defaultFalse() |
||
151 | ->info('To allow the client to set the number of items per page.') |
||
152 | ->end() |
||
153 | ->booleanNode('client_partial') |
||
154 | ->setDeprecated('The use of the `collection.pagination.client_partial` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_client_partial` instead.') |
||
155 | ->defaultFalse() |
||
156 | ->info('To allow the client to enable or disable partial pagination.') |
||
157 | ->end() |
||
158 | ->integerNode('items_per_page') |
||
159 | ->setDeprecated('The use of the `collection.pagination.items_per_page` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_items_per_page` instead.') |
||
160 | ->defaultValue(30) |
||
161 | ->info('The default number of items per page.') |
||
162 | ->end() |
||
163 | ->integerNode('maximum_items_per_page') |
||
164 | ->setDeprecated('The use of the `collection.pagination.maximum_items_per_page` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_maximum_items_per_page` instead.') |
||
165 | ->defaultNull() |
||
166 | ->info('The maximum number of items per page.') |
||
167 | ->end() |
||
168 | ->scalarNode('page_parameter_name')->defaultValue('page')->cannotBeEmpty()->info('The default name of the parameter handling the page number.')->end() |
||
169 | ->scalarNode('enabled_parameter_name')->defaultValue('pagination')->cannotBeEmpty()->info('The name of the query parameter to enable or disable pagination.')->end() |
||
170 | ->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() |
||
171 | ->scalarNode('partial_parameter_name')->defaultValue('partial')->cannotBeEmpty()->info('The name of the query parameter to enable or disable partial pagination.')->end() |
||
172 | ->end() |
||
173 | ->end() |
||
174 | ->end() |
||
175 | ->end() |
||
176 | ->arrayNode('mapping') |
||
177 | ->addDefaultsIfNotSet() |
||
178 | ->children() |
||
179 | ->arrayNode('paths') |
||
180 | ->prototype('scalar')->end() |
||
181 | ->end() |
||
182 | ->end() |
||
183 | ->end() |
||
184 | ->arrayNode('resource_class_directories') |
||
185 | ->prototype('scalar')->end() |
||
186 | ->end() |
||
187 | ->end(); |
||
188 | |||
189 | $this->addDoctrineOrmSection($rootNode); |
||
190 | $this->addDoctrineMongoDbOdmSection($rootNode); |
||
191 | $this->addOAuthSection($rootNode); |
||
192 | $this->addGraphQlSection($rootNode); |
||
193 | $this->addSwaggerSection($rootNode); |
||
194 | $this->addHttpCacheSection($rootNode); |
||
195 | $this->addMercureSection($rootNode); |
||
196 | $this->addMessengerSection($rootNode); |
||
197 | $this->addElasticsearchSection($rootNode); |
||
198 | |||
199 | $this->addExceptionToStatusSection($rootNode); |
||
200 | |||
201 | $this->addFormatSection($rootNode, 'formats', [ |
||
202 | 'jsonld' => ['mime_types' => ['application/ld+json']], |
||
203 | 'json' => ['mime_types' => ['application/json']], // Swagger support |
||
204 | 'html' => ['mime_types' => ['text/html']], // Swagger UI support |
||
205 | ]); |
||
206 | $this->addFormatSection($rootNode, 'patch_formats', []); |
||
207 | $this->addFormatSection($rootNode, 'error_formats', [ |
||
208 | 'jsonproblem' => ['mime_types' => ['application/problem+json']], |
||
209 | 'jsonld' => ['mime_types' => ['application/ld+json']], |
||
210 | ]); |
||
211 | |||
212 | $this->addDefaultsSection($rootNode); |
||
213 | |||
214 | return $treeBuilder; |
||
215 | } |
||
568 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths