| Conditions | 1 |
| Paths | 1 |
| Total Lines | 165 |
| 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 |
||
| 49 | public function getConfigTreeBuilder() |
||
| 50 | { |
||
| 51 | $treeBuilder = new TreeBuilder('swp_bridge', 'array'); |
||
| 52 | $rootNode = $treeBuilder->getRootNode(); |
||
| 53 | |||
| 54 | $rootNode |
||
| 55 | ->children() |
||
| 56 | ->arrayNode('persistence') |
||
| 57 | ->addDefaultsIfNotSet() |
||
| 58 | ->children() |
||
| 59 | ->arrayNode('orm') |
||
| 60 | ->addDefaultsIfNotSet() |
||
| 61 | ->canBeEnabled() |
||
| 62 | ->children() |
||
| 63 | ->arrayNode('classes') |
||
| 64 | ->addDefaultsIfNotSet() |
||
| 65 | ->children() |
||
| 66 | ->arrayNode('package') |
||
| 67 | ->addDefaultsIfNotSet() |
||
| 68 | ->children() |
||
| 69 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Package::class)->end() |
||
| 70 | ->scalarNode('repository')->defaultValue(PackageRepository::class)->end() |
||
| 71 | ->scalarNode('interface')->defaultValue(PackageInterface::class)->end() |
||
| 72 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 73 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 74 | ->end() |
||
| 75 | ->end() |
||
| 76 | ->arrayNode('item') |
||
| 77 | ->addDefaultsIfNotSet() |
||
| 78 | ->children() |
||
| 79 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Item::class)->end() |
||
| 80 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 81 | ->scalarNode('interface')->defaultValue(ItemInterface::class)->end() |
||
| 82 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 83 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 84 | ->end() |
||
| 85 | ->end() |
||
| 86 | ->arrayNode('rendition') |
||
| 87 | ->addDefaultsIfNotSet() |
||
| 88 | ->children() |
||
| 89 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Rendition::class)->end() |
||
| 90 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 91 | ->scalarNode('interface')->defaultValue(RenditionInterface::class)->end() |
||
| 92 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 93 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 94 | ->end() |
||
| 95 | ->end() |
||
| 96 | ->arrayNode('external_data') |
||
| 97 | ->addDefaultsIfNotSet() |
||
| 98 | ->children() |
||
| 99 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(ExternalData::class)->end() |
||
| 100 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 101 | ->scalarNode('interface')->defaultValue(ExternalDataInterface::class)->end() |
||
| 102 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 103 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 104 | ->end() |
||
| 105 | ->end() |
||
| 106 | ->arrayNode('group') |
||
| 107 | ->addDefaultsIfNotSet() |
||
| 108 | ->children() |
||
| 109 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Group::class)->end() |
||
| 110 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 111 | ->scalarNode('interface')->defaultValue(GroupInterface::class)->end() |
||
| 112 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 113 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 114 | ->end() |
||
| 115 | ->end() |
||
| 116 | ->arrayNode('event') |
||
| 117 | ->addDefaultsIfNotSet() |
||
| 118 | ->children() |
||
| 119 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Event::class)->end() |
||
| 120 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 121 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 122 | ->scalarNode('interface')->defaultValue(EventInterface::class)->end() |
||
| 123 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 124 | ->end() |
||
| 125 | ->end() |
||
| 126 | ->arrayNode('event_date') |
||
| 127 | ->addDefaultsIfNotSet() |
||
| 128 | ->children() |
||
| 129 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Date::class)->end() |
||
| 130 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 131 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 132 | ->scalarNode('interface')->defaultValue(DateInterface::class)->end() |
||
| 133 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 134 | ->end() |
||
| 135 | ->end() |
||
| 136 | ->arrayNode('event_location') |
||
| 137 | ->addDefaultsIfNotSet() |
||
| 138 | ->children() |
||
| 139 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Location::class)->end() |
||
| 140 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 141 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 142 | ->scalarNode('interface')->defaultValue(LocationInterface::class)->end() |
||
| 143 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 144 | ->end() |
||
| 145 | ->end() |
||
| 146 | ->arrayNode('event_occur_status') |
||
| 147 | ->addDefaultsIfNotSet() |
||
| 148 | ->children() |
||
| 149 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Event\OccurStatus::class)->end() |
||
| 150 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 151 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 152 | ->scalarNode('interface')->defaultValue(Event\OccurStatusInterface::class)->end() |
||
| 153 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 154 | ->end() |
||
| 155 | ->end() |
||
| 156 | ->arrayNode('event_category') |
||
| 157 | ->addDefaultsIfNotSet() |
||
| 158 | ->children() |
||
| 159 | ->scalarNode('model')->cannotBeEmpty()->defaultValue(Event\Category::class)->end() |
||
| 160 | ->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
||
| 161 | ->scalarNode('factory')->defaultValue(Factory::class)->end() |
||
| 162 | ->scalarNode('interface')->defaultValue(Event\CategoryInterface::class)->end() |
||
| 163 | ->scalarNode('object_manager_name')->defaultValue(null)->end() |
||
| 164 | ->end() |
||
| 165 | ->end() |
||
| 166 | ->end() |
||
| 167 | ->end() |
||
| 168 | ->end() |
||
| 169 | ->end() // orm |
||
| 170 | ->end() |
||
| 171 | ->end() |
||
| 172 | ->arrayNode('api') |
||
| 173 | ->children() |
||
| 174 | ->scalarNode('host') |
||
| 175 | ->info('Hostname of the Content API.') |
||
| 176 | ->isRequired() |
||
| 177 | ->cannotBeEmpty() |
||
| 178 | ->end() |
||
| 179 | ->integerNode('port') |
||
| 180 | ->info('Port of the Content API.') |
||
| 181 | ->defaultValue(80) |
||
| 182 | ->end() |
||
| 183 | ->enumNode('protocol') |
||
| 184 | ->info('Protocol which will be used for connection to the Content Api.') |
||
| 185 | ->values(['http', 'https']) |
||
| 186 | ->defaultValue('https') |
||
| 187 | ->end() |
||
| 188 | ->end() |
||
| 189 | ->end() |
||
| 190 | ->arrayNode('auth') |
||
| 191 | ->children() |
||
| 192 | ->scalarNode('client_id') |
||
| 193 | ->info('Client ID for OAuth2 authentication for the Content Api.') |
||
| 194 | ->isRequired() |
||
| 195 | ->cannotBeEmpty() |
||
| 196 | ->end() |
||
| 197 | ->scalarNode('username') |
||
| 198 | ->info('Username for OAuth2 authentication for the Content Api.') |
||
| 199 | ->isRequired() |
||
| 200 | ->cannotBeEmpty() |
||
| 201 | ->end() |
||
| 202 | ->scalarNode('password') |
||
| 203 | ->info('Password for OAuth2 authentication for the Content Api.') |
||
| 204 | ->isRequired() |
||
| 205 | ->cannotBeEmpty() |
||
| 206 | ->end() |
||
| 207 | ->end() |
||
| 208 | ->end() |
||
| 209 | ->variableNode('options')->end() |
||
| 210 | ->end(); |
||
| 211 | |||
| 212 | return $treeBuilder; |
||
| 213 | } |
||
| 214 | } |
||
| 215 |