| Conditions | 1 |
| Paths | 1 |
| Total Lines | 117 |
| 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 |
||
| 29 | public function addSemanticConfig(NodeBuilder $nodeBuilder) |
||
| 30 | { |
||
| 31 | $nodeBuilder |
||
| 32 | ->scalarNode('repository')->info('The repository to use. Choose among ezpublish.repositories.')->end() |
||
| 33 | // @deprecated |
||
| 34 | // Use ezpublish.repositories / repository settings instead. |
||
| 35 | ->arrayNode('database') |
||
| 36 | ->info('DEPRECATED. Use ezpublish.repositories / repository settings instead.') |
||
| 37 | ->children() |
||
| 38 | ->enumNode('type')->values(['mysql', 'pgsql', 'sqlite'])->info('The database driver. Can be mysql, pgsql or sqlite.')->end() |
||
| 39 | ->scalarNode('server')->end() |
||
| 40 | ->scalarNode('port')->end() |
||
| 41 | ->scalarNode('user')->cannotBeEmpty()->end() |
||
| 42 | ->scalarNode('password')->end() |
||
| 43 | ->scalarNode('database_name')->cannotBeEmpty()->end() |
||
| 44 | ->scalarNode('charset')->defaultValue('utf8')->end() |
||
| 45 | ->scalarNode('socket')->end() |
||
| 46 | ->arrayNode('options') |
||
| 47 | ->info('Arbitrary options, supported by your DB driver ("driver-opts" in PDO)') |
||
| 48 | ->example(['foo' => 'bar', 'someOptionName' => ['one', 'two', 'three']]) |
||
| 49 | ->useAttributeAsKey('key') |
||
| 50 | ->prototype('variable')->end() |
||
| 51 | ->end() |
||
| 52 | ->scalarNode('dsn')->info('Full database DSN. Will replace settings above.')->example('mysql://root:root@localhost:3306/ezdemo')->end() |
||
| 53 | ->end() |
||
| 54 | ->end() |
||
| 55 | ->scalarNode('cache_service_name') |
||
| 56 | ->example('cache.app') |
||
| 57 | ->info('The cache pool service name to use for a siteaccess / siteaccess-group, *must* be present.') |
||
| 58 | ->end() |
||
| 59 | ->scalarNode('var_dir') |
||
| 60 | ->cannotBeEmpty() |
||
| 61 | ->example('var/ezdemo_site') |
||
| 62 | ->info('The directory relative to web/ where files are stored. Default value is "var"') |
||
| 63 | ->end() |
||
| 64 | ->arrayNode('api_keys') |
||
| 65 | ->info('Collection of API keys') |
||
| 66 | ->addDefaultsIfNotSet() |
||
| 67 | ->children() |
||
| 68 | ->scalarNode('google_maps') |
||
| 69 | ->setDeprecated('The child node "%node%" at path "%path%" is no longer used and deprecated.') |
||
| 70 | ->info('Google Maps API Key, required as of Google Maps v3 to make sure maps show up correctly.') |
||
| 71 | ->end() |
||
| 72 | ->end() |
||
| 73 | ->end() |
||
| 74 | ->scalarNode('storage_dir') |
||
| 75 | ->cannotBeEmpty() |
||
| 76 | ->info("Directory where to place new files for storage, it's relative to var directory. Default value is 'storage'") |
||
| 77 | ->end() |
||
| 78 | ->scalarNode('binary_dir') |
||
| 79 | ->cannotBeEmpty() |
||
| 80 | ->info('Directory where binary files (from ezbinaryfile field type) are stored. Default value is "original"') |
||
| 81 | ->end() |
||
| 82 | // @deprecated since 5.3. Will be removed in 6.x. |
||
| 83 | ->scalarNode('session_name') |
||
| 84 | ->info('DEPRECATED. Use session.name instead.') |
||
| 85 | ->end() |
||
| 86 | ->arrayNode('session') |
||
| 87 | ->info('Session options. Will override options defined in Symfony framework.session.*') |
||
| 88 | ->children() |
||
| 89 | ->scalarNode('name') |
||
| 90 | ->info('The session name. If you want a session name per siteaccess, use "{siteaccess_hash}" token. Will override default session name from framework.session.name') |
||
| 91 | ->example(['session' => ['name' => 'eZSESSID{siteaccess_hash}']]) |
||
| 92 | ->end() |
||
| 93 | ->scalarNode('cookie_lifetime')->end() |
||
| 94 | ->scalarNode('cookie_path')->end() |
||
| 95 | ->scalarNode('cookie_domain')->end() |
||
| 96 | ->booleanNode('cookie_secure')->end() |
||
| 97 | ->booleanNode('cookie_httponly')->end() |
||
| 98 | ->end() |
||
| 99 | ->end() |
||
| 100 | ->scalarNode('pagelayout') |
||
| 101 | ->info('The default layout to use') |
||
| 102 | ->example('AppBundle::pagelayout.html.twig') |
||
| 103 | ->setDeprecated('The "pagelayout" option is deprecated. Use "page_layout" instead.') |
||
| 104 | ->end() |
||
| 105 | ->scalarNode('page_layout') |
||
| 106 | ->info('The default layout to use') |
||
| 107 | ->example('AppBundle::page_layout.html.twig') |
||
| 108 | ->end() |
||
| 109 | ->scalarNode('index_page') |
||
| 110 | ->info('The page that the index page will show. Default value is null.') |
||
| 111 | ->example('/Getting-Started') |
||
| 112 | ->end() |
||
| 113 | ->scalarNode('default_page') |
||
| 114 | ->info('The default page to show, e.g. after user login this will be used for default redirection. If provided, will override "default_target_path" from security.yml.') |
||
| 115 | ->example('/Getting-Started') |
||
| 116 | ->end() |
||
| 117 | ->arrayNode('http_cache') |
||
| 118 | ->info('Settings related to Http cache') |
||
| 119 | ->children() |
||
| 120 | ->arrayNode('purge_servers') |
||
| 121 | ->info('Servers to use for Http PURGE (will NOT be used if ezpublish.http_cache.purge_type is "local").') |
||
| 122 | ->example(['http://localhost/', 'http://another.server/']) |
||
| 123 | ->requiresAtLeastOneElement() |
||
| 124 | ->prototype('scalar')->end() |
||
| 125 | ->end() |
||
| 126 | ->end() |
||
| 127 | ->end() |
||
| 128 | ->scalarNode('anonymous_user_id') |
||
| 129 | ->cannotBeEmpty() |
||
| 130 | ->example('10') |
||
| 131 | ->info('The ID of the user used for everyone who is not logged in.') |
||
| 132 | ->end() |
||
| 133 | ->arrayNode('user') |
||
| 134 | ->children() |
||
| 135 | ->scalarNode('layout') |
||
| 136 | ->info('Layout template to use for user related actions. This is most likely the base pagelayout template of your site.') |
||
| 137 | ->example(['layout' => 'eZDemoBundle::pagelayout.html.twig']) |
||
| 138 | ->end() |
||
| 139 | ->scalarNode('login_template') |
||
| 140 | ->info('Template to use for login form. Defaults to EzPublishCoreBundle:security:login.html.twig') |
||
| 141 | ->example(['login_template' => 'AcmeTestBundle:User:login.html.twig']) |
||
| 142 | ->end() |
||
| 143 | ->end() |
||
| 144 | ->end(); |
||
| 145 | } |
||
| 146 | |||
| 306 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.