| Conditions | 1 |
| Paths | 1 |
| Total Lines | 95 |
| Code Lines | 91 |
| 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 |
||
| 38 | public function getConfigTreeBuilder() |
||
| 39 | { |
||
| 40 | $treeBuilder = new TreeBuilder(); |
||
| 41 | $rootNode = $treeBuilder->root('swp_bridge', 'array'); |
||
| 42 | |||
| 43 | $rootNode |
||
| 44 | ->children() |
||
| 45 | ->arrayNode('persistence') |
||
| 46 | ->addDefaultsIfNotSet() |
||
| 47 | ->children() |
||
| 48 | ->arrayNode('orm') |
||
| 49 | ->addDefaultsIfNotSet() |
||
| 50 | ->canBeEnabled() |
||
| 51 | ->children() |
||
| 52 | ->arrayNode('classes') |
||
| 53 | ->addDefaultsIfNotSet() |
||
| 54 | ->children() |
||
| 55 | ->arrayNode('package') |
||
| 56 | ->addDefaultsIfNotSet() |
||
| 57 | ->children() |
||
| 58 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Package::class)->end() |
||
| 59 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 60 | ->scalarNode('interface')->defaultValue(PackageInterface::class)->end() |
||
| 61 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 62 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 63 | ->end() |
||
| 64 | ->end() |
||
| 65 | ->arrayNode('item') |
||
| 66 | ->addDefaultsIfNotSet() |
||
| 67 | ->children() |
||
| 68 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Item::class)->end() |
||
| 69 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 70 | ->scalarNode('interface')->defaultValue(ItemInterface::class)->end() |
||
| 71 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 72 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 73 | ->end() |
||
| 74 | ->end() |
||
| 75 | ->arrayNode('rendition') |
||
| 76 | ->addDefaultsIfNotSet() |
||
| 77 | ->children() |
||
| 78 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Rendition::class)->end() |
||
| 79 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 80 | ->scalarNode('interface')->defaultValue(RenditionInterface::class)->end() |
||
| 81 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 82 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 83 | ->end() |
||
| 84 | ->end() |
||
| 85 | ->end() |
||
| 86 | ->end() |
||
| 87 | ->end() |
||
| 88 | ->end() // orm |
||
| 89 | ->end() |
||
| 90 | ->end() |
||
| 91 | ->arrayNode('api') |
||
| 92 | ->children() |
||
| 93 | ->scalarNode('host') |
||
| 94 | ->info('Hostname of the Content API.') |
||
| 95 | ->isRequired() |
||
| 96 | ->cannotBeEmpty() |
||
| 97 | ->end() |
||
| 98 | ->integerNode('port') |
||
| 99 | ->info('Port of the Content API.') |
||
| 100 | ->defaultValue(80) |
||
| 101 | ->end() |
||
| 102 | ->enumNode('protocol') |
||
| 103 | ->info('Protocol which will be used for connection to the Content Api.') |
||
| 104 | ->values(['http', 'https']) |
||
| 105 | ->defaultValue('https') |
||
| 106 | ->end() |
||
| 107 | ->end() |
||
| 108 | ->end() |
||
| 109 | ->arrayNode('auth') |
||
| 110 | ->children() |
||
| 111 | ->scalarNode('client_id') |
||
| 112 | ->info('Client ID for OAuth2 authentication for the Content Api.') |
||
| 113 | ->isRequired() |
||
| 114 | ->cannotBeEmpty() |
||
| 115 | ->end() |
||
| 116 | ->scalarNode('username') |
||
| 117 | ->info('Username for OAuth2 authentication for the Content Api.') |
||
| 118 | ->isRequired() |
||
| 119 | ->cannotBeEmpty() |
||
| 120 | ->end() |
||
| 121 | ->scalarNode('password') |
||
| 122 | ->info('Password for OAuth2 authentication for the Content Api.') |
||
| 123 | ->isRequired() |
||
| 124 | ->cannotBeEmpty() |
||
| 125 | ->end() |
||
| 126 | ->end() |
||
| 127 | ->end() |
||
| 128 | ->variableNode('options')->end() |
||
| 129 | ->end(); |
||
| 130 | |||
| 131 | return $treeBuilder; |
||
| 132 | } |
||
| 133 | } |
||
| 134 |