Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 62 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | 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 |
||
26 | public function getConfigTreeBuilder(): TreeBuilder |
||
27 | { |
||
28 | $treeBuilder = new TreeBuilder('bitbag_sylius_wishlist_plugin'); |
||
29 | $rootNode = $treeBuilder->getRootNode(); |
||
30 | /** @phpstan-ignore-next-line */ |
||
31 | $rootNode |
||
32 | ->children() |
||
33 | ->scalarNode('wishlist_cookie_token') |
||
34 | ->defaultValue('wishlist_cookie_token') |
||
35 | ->cannotBeEmpty() |
||
36 | ->end() |
||
37 | ->arrayNode('allowed_mime_types') |
||
38 | ->defaultValue([ |
||
39 | 'text/csv', |
||
40 | 'text/plain', |
||
41 | 'application/csv', |
||
42 | 'text/comma-separated-values', |
||
43 | 'application/excel', |
||
44 | 'application/vnd.ms-excel', |
||
45 | 'application/vnd.msexcel', |
||
46 | 'text/anytext', |
||
47 | 'application/octet-stream', |
||
48 | 'application/txt', |
||
49 | ]) |
||
50 | ->requiresAtLeastOneElement() |
||
51 | ->scalarPrototype()->end() |
||
52 | ->end() |
||
53 | ->arrayNode('resources') |
||
54 | ->addDefaultsIfNotSet() |
||
55 | ->children() |
||
56 | ->arrayNode('wishlist') |
||
57 | ->addDefaultsIfNotSet() |
||
58 | ->children() |
||
59 | ->variableNode('options')->end() |
||
60 | ->arrayNode('classes') |
||
61 | ->addDefaultsIfNotSet() |
||
62 | ->children() |
||
63 | ->scalarNode('model')->defaultValue(Wishlist::class)->cannotBeEmpty()->end() |
||
64 | ->scalarNode('interface')->defaultValue(WishlistInterface::class)->cannotBeEmpty()->end() |
||
65 | ->scalarNode('repository')->defaultValue(WishlistRepository::class)->cannotBeEmpty()->end() |
||
66 | ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
||
67 | ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() |
||
68 | ->end() |
||
69 | ->end() |
||
70 | ->end() |
||
71 | ->end() |
||
72 | ->arrayNode('wishlist_product') |
||
73 | ->addDefaultsIfNotSet() |
||
74 | ->children() |
||
75 | ->variableNode('options')->end() |
||
76 | ->arrayNode('classes') |
||
77 | ->addDefaultsIfNotSet() |
||
78 | ->children() |
||
79 | ->scalarNode('model')->defaultValue(WishlistProduct::class)->cannotBeEmpty()->end() |
||
80 | ->scalarNode('interface')->defaultValue(WishlistProductInterface::class)->cannotBeEmpty()->end() |
||
81 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->cannotBeEmpty()->end() |
||
82 | ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
||
83 | ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() |
||
84 | ->end() |
||
85 | ->end() |
||
86 | ->end() |
||
87 | ->end() |
||
88 | ->end() |
||
89 | ->end() |
||
90 | ->end() |
||
91 | ; |
||
92 | |||
93 | return $treeBuilder; |
||
94 | } |
||
96 |