Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 55
Code Lines 47

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 47
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 47
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 55
ccs 47
cts 47
cp 1
crap 1
rs 9.1563

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
namespace Azine\EmailBundle\DependencyInjection;
4
5
use Azine\EmailBundle\Services\AzineTemplateProvider;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
/**
10
 * Define the possible configuration settings for the config.yml/.xml.
11
 */
12
class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 8
    public function getConfigTreeBuilder()
18
    {
19 8
        $treeBuilder = new TreeBuilder();
20 8
        $rootNode = $treeBuilder->root('azine_email');
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\Config...der\TreeBuilder::root() has been deprecated: since Symfony 4.3, pass the root name to the constructor instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
        $rootNode = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('azine_email');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
21
22
        $rootNode
23 8
            ->children()
24 8
                ->scalarNode(AzineEmailExtension::RECIPIENT_CLASS)->isRequired()->defaultValue('Acme\\SomeBundle\\Entity\\User')->info('the class of your implementation of the RecipientInterface')->end()
25 8
                ->scalarNode(AzineEmailExtension::RECIPIENT_NEWSLETTER_FIELD)->defaultValue('newsletter')->info('the fieldname of the boolean field on the recipient class indicating, that a newsletter should be sent or not')->end()
26 8
                ->scalarNode(AzineEmailExtension::NOTIFIER_SERVICE)->defaultValue('azine_email.example.notifier_service')->info('the service-id of your implementation of the nofitier service to be used')->end()
27 8
                ->scalarNode(AzineEmailExtension::TEMPLATE_PROVIDER)->isRequired()->defaultValue('azine_email.example.template_provider')->info('the service-id of your implementation of the template provider service to be used')->end()
28 8
                ->scalarNode(AzineEmailExtension::RECIPIENT_PROVIDER)->defaultValue('azine_email.default.recipient_provider')->info('the service-id of the implementation of the RecipientProviderInterface to be used')->end()
29 8
                ->scalarNode(AzineEmailExtension::TEMPLATE_TWIG_SWIFT_MAILER)->defaultValue('azine_email.default.template_twig_swift_mailer')->info('the service-id of the mailer service to be used')->end()
30 8
                ->arrayNode(AzineEmailExtension::NO_REPLY)->isRequired()
31 8
                    ->addDefaultsIfNotSet()
32 8
                    ->children()
33 8
                        ->scalarNode(AzineEmailExtension::NO_REPLY_EMAIL_ADDRESS)->defaultValue('[email protected]')->isRequired()->info('the no-reply email-address')->isRequired()->end()
34 8
                        ->scalarNode(AzineEmailExtension::NO_REPLY_EMAIL_NAME)->defaultValue('notification daemon')->isRequired()->info("the name to appear with the 'no-reply'-address.")->isRequired()->end()
35 8
                        ->end()
36 8
                    ->end()
37 8
                ->scalarNode(AzineEmailExtension::TEMPLATE_IMAGE_DIR)->defaultValue('%kernel.root_dir%/../vendor/azine/email-bundle/Azine/EmailBundle/Resources/htmlTemplateImages/')->info('absolute path to the image-folder containing the images used in your templates.')->end()
38 8
                ->variableNode(AzineEmailExtension::ALLOWED_IMAGES_FOLDERS)->defaultValue(array())->info('list of folders from which images are allowed to be embeded into emails')->end()
39 8
                ->arrayNode(AzineEmailExtension::NEWSLETTER)->info('newsletter configuration')
40 8
                    ->addDefaultsIfNotSet()
41 8
                    ->children()
42 8
                        ->scalarNode(AzineEmailExtension::NEWSLETTER_INTERVAL)->defaultValue('14')->info('number of days between newsletters')->end()
43 8
                        ->scalarNode(AzineEmailExtension::NEWSLETTER_SEND_TIME)->defaultValue('10:00')->info('time of the day, when newsletters should be sent, 24h-format => e.g. 23:59')->end()
44 8
                    ->end()
45 8
                ->end()
46
47 8
                ->arrayNode(AzineEmailExtension::TEMPLATES)->info('templates configuration')
48 8
                    ->addDefaultsIfNotSet()
49 8
                    ->children()
50 8
                           ->scalarNode(AzineEmailExtension::NEWSLETTER_TEMPLATE)->defaultValue(AzineTemplateProvider::NEWSLETTER_TEMPLATE)->info('wrapper template id (without ending) for the newsletter')->end()
51 8
                        ->scalarNode(AzineEmailExtension::NOTIFICATIONS_TEMPLATE)->defaultValue(AzineTemplateProvider::NOTIFICATIONS_TEMPLATE)->info('wrapper template id (without ending) for notifications')->end()
52 8
                        ->scalarNode(AzineEmailExtension::CONTENT_ITEM_TEMPLATE)->defaultValue(AzineTemplateProvider::CONTENT_ITEM_MESSAGE_TEMPLATE)->info('template id (without ending) for notification content items')->end()
53 8
                    ->end()
54 8
                ->end()
55
56 8
                ->scalarNode(AzineEmailExtension::TRACKING_PARAM_CAMPAIGN_NAME)->defaultValue('utm_campaign')->info('See https://ga-dev-tools.appspot.com/campaign-url-builder/ for more infos')->end()
57 8
                ->scalarNode(AzineEmailExtension::TRACKING_PARAM_CAMPAIGN_TERM)->defaultValue('utm_term')->info('See https://ga-dev-tools.appspot.com/campaign-url-builder/ for more infos')->end()
58 8
                ->scalarNode(AzineEmailExtension::TRACKING_PARAM_CAMPAIGN_CONTENT)->defaultValue('utm_content')->info('See https://ga-dev-tools.appspot.com/campaign-url-builder/ for more infos')->end()
59 8
                ->scalarNode(AzineEmailExtension::TRACKING_PARAM_CAMPAIGN_MEDIUM)->defaultValue('utm_medium')->info('See https://ga-dev-tools.appspot.com/campaign-url-builder/ for more infos')->end()
60 8
                ->scalarNode(AzineEmailExtension::TRACKING_PARAM_CAMPAIGN_SOURCE)->defaultValue('utm_source')->info('See https://ga-dev-tools.appspot.com/campaign-url-builder/ for more infos')->end()
61 8
                ->scalarNode(AzineEmailExtension::EMAIL_TRACKING_BASE_URL)->defaultValue(null)->info('See the README.md file for more information')->end()
62 8
                ->scalarNode(AzineEmailExtension::EMAIL_TRACKING_CODE_BUILDER)->defaultValue('azine.email.open.tracking.code.builder.ga.or.piwik')->info('Defaults to the AzineEmailOpenTrackingCodeBuilder. See the README.md file for more information')->end()
63 8
                ->arrayNode(AzineEmailExtension::DOMAINS_FOR_TRACKING)->info("Defaults to 'all domains' => empty array.")
64 8
                    ->prototype('scalar')->end()
65 8
                ->end()
66
67 8
                ->scalarNode(AzineEmailExtension::WEB_VIEW_RETENTION)->defaultValue('90')->info('number of days that emails should be available in web-view')->end()
68 8
                ->scalarNode(AzineEmailExtension::WEB_VIEW_SERVICE)->defaultValue('azine_email.example.web.view.service')->info('the service-id of your implementation of the web view service to be used')->end()
69
            ;
70
71 8
        return $treeBuilder;
72
    }
73
}
74