Completed
Pull Request — master (#30)
by Matthew
11:23
created

Configuration::addRabbitMqSslOptions()   C

Complexity

Conditions 8
Paths 1

Size

Total Lines 32
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 8.048

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 20
cts 22
cp 0.9091
rs 5.3846
c 0
b 0
f 0
cc 8
eloc 21
nc 1
nop 0
crap 8.048
1
<?php
2
3
namespace Dtc\QueueBundle\DependencyInjection;
4
5
use Dtc\QueueBundle\Manager\PriorityJobManager;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
use Symfony\Component\HttpKernel\Kernel;
9
10
class Configuration implements ConfigurationInterface
11
{
12
    /**
13
     * Generates the configuration tree.
14
     *
15
     * @return TreeBuilder
16
     */
17 8
    public function getConfigTreeBuilder()
18
    {
19 8
        $treeBuilder = new TreeBuilder();
20 8
        $rootNode = $treeBuilder->root('dtc_queue');
21
22
        $node = $rootNode
23 8
            ->children()
24 8
                ->append($this->addOrm())
25 8
                ->append($this->addOdm())
26 8
                ->append($this->addManager())
27 8
                ->append($this->addTimings())
28 8
                ->append($this->addBeanstalkd())
29 8
                ->append($this->addRabbitMq())
30 8
                ->append($this->addRedis())
31 8
                ->append($this->addAdmin())
32 8
                ->append($this->addClasses())
33 8
                ->append($this->addPriority())
34 8
                ->append($this->addRetry());
35
36 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'document_manager', 'The "%node% option is deprecated, Use "odm: { document_manager: ... }" instead.');
37 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'entity_manager', 'The "%node% option is deprecated, Use "odm: { entity_manager: ... }" instead.');
38 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'default_manager', 'The "%node% option is deprecated, Use "manager: { job: ... }" instead.');
39 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'run_manager', 'The "%node% option is deprecated, Use "manager: { run: ... }" instead.');
40 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'job_timing_manager', 'The "%node% option is deprecated, Use "manager: { job_timing: ... }" instead.');
41 8
        $node = $this->setDeprecatedNode($node, 'booleanNode', 'record_timings', 'The "%node% option is deprecated, Use "timings: { record: ... }" instead.');
42 8
        $node = $this->setDeprecatedNode($node, 'integerNode', 'record_timings_timezone_offset', 'The "%node% option is deprecated, Use "record: { timezone_offset: ... }" instead.');
43 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'class_job', 'The "%node% option is deprecated, Use "class: { job: ... }" instead.');
44 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'class_job_archive', 'The "%node% option is deprecated, Use "class: { job_archive: ... }" instead.');
45 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'class_run', 'The "%node% option is deprecated, Use "class: { run: ... }" instead.');
46 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'class_run_archive', 'The "%node% option is deprecated, Use "class: { run_archive: ... }" instead.');
47 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'class_job_timing', 'The "%node% option is deprecated, Use "class: { job_timing: ... }" instead.');
48 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'priority_max', 'The "%node% option is deprecated, Use "priority: { max: ... }" instead.');
49 8
        $node = $this->setDeprecatedNode($node, 'scalarNode', 'priority_direction', 'The "%node% option is deprecated, Use "priority: { direction: ... }" instead.');
50 8
        $node->end();
51
52 8
        return $treeBuilder;
53
    }
54
55 8
    public function setDeprecatedNode($node, $type, $name, $deprecatedMessage)
56
    {
57 8
        $node = $node->$type($name);
58
59 8
        if (Kernel::VERSION_ID >= 30400) {
60 8
            $node = $node->setDeprecated($deprecatedMessage);
61 8
        }
62
63 8
        return $node->end();
64
    }
65
66 8
    protected function addTimings()
67
    {
68 8
        $treeBuilder = new TreeBuilder();
69 8
        $rootNode = $treeBuilder->root('timings');
70
        $rootNode
71 8
            ->addDefaultsIfNotSet()
72 8
            ->children()
73 8
                ->booleanNode('record')
74 8
                    ->info('Set this to true to record timings (used on the Trends page)')
75 8
                    ->defaultFalse()
76 8
                ->end()
77 8
                ->floatNode('timezone_offset')
78 8
                    ->defaultValue(0)
79 8
                    ->info('Set this some integer offset from GMT in case your database is not storing things in the proper timezone and the dates look off on the Trends page')
80 8
                    ->max(24)
81 8
                    ->min(-24)
82 8
                ->end()
83 8
            ->end();
84
85 8
        return $rootNode;
86
    }
87
88 8 View Code Duplication
    protected function addOrm()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
89
    {
90 8
        $treeBuilder = new TreeBuilder();
91 8
        $rootNode = $treeBuilder->root('orm');
92
        $rootNode
93 8
            ->addDefaultsIfNotSet()
94 8
            ->children()
95 8
                ->scalarNode('entity_manager')
96 8
                    ->info('This only needs to be set if orm is used for any of the managers, and you do not want to use the default entity manager')
97 8
                    ->defaultValue('default')
98 8
                    ->cannotBeEmpty()
99 8
                ->end()
100 8
            ->end();
101
102 8
        return $rootNode;
103
    }
104
105 8 View Code Duplication
    protected function addOdm()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
106
    {
107 8
        $treeBuilder = new TreeBuilder();
108 8
        $rootNode = $treeBuilder->root('odm');
109
        $rootNode
110 8
            ->addDefaultsIfNotSet()
111 8
            ->children()
112 8
                ->scalarNode('document_manager')
113 8
                    ->info('This only needs to be set if odm is used for any of the managers, and you do not want to use the default document manager')
114 8
                    ->defaultValue('default')
115 8
                    ->cannotBeEmpty()
116 8
                ->end()
117 8
            ->end();
118
119 8
        return $rootNode;
120
    }
121
122 8
    protected function addManager()
123
    {
124 8
        $treeBuilder = new TreeBuilder();
125 8
        $rootNode = $treeBuilder->root('manager');
126
        $rootNode
127 8
            ->addDefaultsIfNotSet()
128 8
            ->children()
129 8
                ->scalarNode('job')
130 8
                    ->defaultValue('odm')
131 8
                    ->info('This can be [odm|orm|beanstalkd|rabbit_mq|redis|(your-own-custom-one)]')
132 8
                    ->cannotBeEmpty()
133 8
                ->end()
134 8
                ->scalarNode('run')->end()
135 8
                ->scalarNode('job_timing')->end()
136 8
            ->end();
137
138 8
        return $rootNode;
139
    }
140
141 8
    protected function addBeanstalkd()
142
    {
143 8
        $treeBuilder = new TreeBuilder();
144 8
        $rootNode = $treeBuilder->root('beanstalkd');
145
        $rootNode
146 8
            ->children()
147 8
                ->scalarNode('host')->end()
148 8
                ->scalarNode('tube')->end()
149 8
            ->end();
150
151 8
        return $rootNode;
152
    }
153
154 8
    protected function addRetry()
155
    {
156 8
        $treeBuilder = new TreeBuilder();
157 8
        $rootNode = $treeBuilder->root('retry');
158
        $rootNode
159 8
            ->addDefaultsIfNotSet()
160 8
            ->children()
161 8
                ->arrayNode('max')
162 8
                    ->addDefaultsIfNotSet()
163 8
                    ->children()
164 8
                        ->integerNode('retries')
165 8
                            ->info('This the maximum total number of retries of any type.')
166 8
                            ->defaultValue(3)
167 8
                        ->end()
168 8
                        ->integerNode('failures')
169 8
                            ->info('This the maximum total number of failures before a job is marked as hitting the maximum failures.')
170 8
                            ->defaultValue(1)
171 8
                        ->end()
172 8
                        ->integerNode('exceptions')
173 8
                            ->info('This the maximum total number of exceptions before a job is marked as hitting the maximum exceptions.')
174 8
                            ->defaultValue(2)
175 8
                        ->end()
176 8
                        ->integerNode('stalls')
177 8
                            ->info('This the maximum total number of exceptions before a job is marked as hitting the maximum exceptions.')
178 8
                            ->defaultValue(2)
179 8
                        ->end()
180 8
                    ->end()
181 8
                ->end()
182 8
                ->arrayNode('auto')
183 8
                    ->addDefaultsIfNotSet()
184 8
                    ->children()
185 8
                        ->booleanNode('failure')
186 8
                            ->info('Instantly re-queue the job on failure.')
187 8
                            ->defaultTrue()
188 8
                        ->end()
189 8
                        ->booleanNode('exception')
190 8
                            ->info('Instantly re-queue the job on exception.')
191 8
                            ->defaultFalse()
192 8
                        ->end()
193 8
                    ->end()
194 8
                ->end()
195 8
            ->end();
196
197 8
        return $rootNode;
198
    }
199
200 8
    protected function addPriority()
201
    {
202 8
        $treeBuilder = new TreeBuilder();
203 8
        $rootNode = $treeBuilder->root('priority');
204
        $rootNode
205 8
            ->addDefaultsIfNotSet()
206 8
            ->children()
207 8
                ->integerNode('max')
208 8
                    ->defaultValue(255)
209 8
                    ->info('Maximum priority value.')
210 8
                    ->min(1)
211 8
                ->end()
212 8
                ->enumNode('direction')
213 8
                    ->values([PriorityJobManager::PRIORITY_ASC, PriorityJobManager::PRIORITY_DESC])
214 8
                    ->info('Whether 1 is high priority or low prioirty.  '.PriorityJobManager::PRIORITY_ASC.' means 1 is low, '.PriorityJobManager::PRIORITY_DESC.' means 1 is high.')
215 8
                    ->defaultValue(PriorityJobManager::PRIORITY_DESC)
216 8
                ->end()
217 8
            ->end();
218
219 8
        return $rootNode;
220
    }
221
222 8
    protected function addClasses()
223
    {
224 8
        $treeBuilder = new TreeBuilder();
225 8
        $rootNode = $treeBuilder->root('class');
226
        $rootNode
227 8
            ->children()
228 8
                ->scalarNode('job')
229 8
                    ->info('If you want to override the Job class, put the class name here.')->end()
230 8
                ->scalarNode('job_archive')
231 8
                    ->info('If you want to override the JobArchive class, put the class name here.')->end()
232 8
                ->scalarNode('job_timing')
233 8
                    ->info('If you want to override the JobTiming class, put the class name here.')->end()
234 8
                ->scalarNode('run')
235 8
                    ->info('If you want to override the Run class, put the class name here.')->end()
236 8
                ->scalarNode('run_archive')
237 8
                    ->info('If you want to override the RunArchive class, put the class name here.')->end()
238 8
            ->end();
239
240 8
        return $rootNode;
241
    }
242
243 8 View Code Duplication
    protected function addAdmin()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
244
    {
245 8
        $treeBuilder = new TreeBuilder();
246 8
        $rootNode = $treeBuilder->root('admin');
247
        $rootNode
248 8
            ->addDefaultsIfNotSet()
249 8
            ->children()
250 8
                ->scalarNode('chartjs')
251 8
                    ->defaultValue('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.bundle.min.js')
252 8
                    ->info('This can be changed to say a locally hosted path or url.')->end()
253 8
                ->end()
254 8
            ->end();
255
256 8
        return $rootNode;
257
    }
258
259 8
    protected function addSncRedis()
260
    {
261 8
        $treeBuilder = new TreeBuilder();
262 8
        $rootNode = $treeBuilder->root('snc_redis');
263
        $rootNode
264 8
            ->children()
265 8
                ->enumNode('type')
266 8
                    ->values(['predis', 'phpredis'])
267 8
                    ->defaultNull()->end()
268 8
                ->scalarNode('alias')
269 8
                    ->defaultNull()->end()
270 8
            ->end()
271 View Code Duplication
            ->validate()->ifTrue(function ($node) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
272 1
                if (isset($node['type']) && !isset($node['alias'])) {
273 1
                    return true;
274
                }
275 1
                if (isset($node['alias']) && !isset($node['type'])) {
276 1
                    return true;
277
                }
278
279 1
                return false;
280 8
            })->thenInvalid('if alias or type is set, then both must be set')->end();
281
282 8
        return $rootNode;
283
    }
284
285 8
    protected function addPredis()
286
    {
287 8
        $treeBuilder = new TreeBuilder();
288 8
        $rootNode = $treeBuilder->root('predis');
289
        $rootNode
290 8
            ->children()
291 8
                ->scalarNode('dsn')->defaultNull()->end()
292 8
                ->append($this->addPredisArgs())
293 8
            ->end()
294
            ->validate()->ifTrue(function ($node) {
295 1
                if (isset($node['dsn']) && (isset($node['connection_parameters']['host']) || isset($node['connection_parameters']['port']))) {
296
                    return true;
297
                }
298
299 1
                return false;
300 8
            })->thenInvalid('if dsn is set, do not use connection_parameters for predis (and vice-versa)')->end();
301
302 8
        return $rootNode;
303
    }
304
305 8
    protected function addRedis()
306
    {
307 8
        $treeBuilder = new TreeBuilder();
308 8
        $rootNode = $treeBuilder->root('redis');
309
        $rootNode
310 8
            ->addDefaultsIfNotSet()
311 8
            ->children()
312 8
                ->scalarNode('prefix')->defaultValue('dtc_queue_')->end()
313 8
                ->append($this->addSncRedis())
314 8
                ->append($this->addPredis())
315 8
                ->append($this->addPhpRedisArgs())
316 8
            ->end()
317
            ->validate()->ifTrue(function ($node) {
318 4 View Code Duplication
                if ((isset($node['predis']['dsn']) || isset($node['predis']['connection_parameters']['host'])) &&
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
319 4
                    (isset($node['snc_redis']['type']) || isset($node['phpredis']['host']))) {
320
                    return true;
321
                }
322 4 View Code Duplication
                if (isset($node['snc_redis']['type']) &&
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
323 1
                    (isset($node['predis']['dsn']) || isset($node['predis']['connection_parameters']['host']) ||
324 4
                    isset($node['phpredis']['host']))) {
325
                    return true;
326
                }
327 4
                if (isset($node['phpredis']['host']) &&
328 2
                    (isset($node['snc_redis']['type']) || isset($node['predis']['dsn']) ||
329 4
                     isset($node['predis']['connection_parameters']['host']))) {
330
                    return true;
331
                }
332
333 4
                return false;
334 8
            })->thenInvalid('only one of [snc_redis | predis | phpredis] should be set')->end();
335
336 8
        return $rootNode;
337
    }
338
339 8
    protected function addPhpRedisArgs()
340
    {
341 8
        $treeBuilder = new TreeBuilder();
342 8
        $rootNode = $treeBuilder->root('phpredis');
343
        $rootNode
344 8
            ->addDefaultsIfNotSet()
345 8
            ->children()
346 8
                ->scalarNode('host')->end()
347 8
                ->integerNode('port')->defaultValue(6379)->end()
348 8
                ->floatNode('timeout')->defaultValue(0)->end()
349 8
                ->integerNode('retry_interval')->defaultNull()->end()
350 8
                ->floatNode('read_timeout')->defaultValue(0)->end()
351 8
                ->scalarNode('auth')->end()
352 8
            ->end()
353
            ->validate()->ifTrue(function ($node) {
354 2
                if (!empty($node) && !isset($node['host'])) {
355
                    return true;
356
                }
357
358 2
                return false;
359 8
            })->thenInvalid('phpredis host should be set')->end();
360
361 8
        return $rootNode;
362
    }
363
364 8
    protected function addPredisArgs()
365
    {
366 8
        $treeBuilder = new TreeBuilder();
367 8
        $rootNode = $treeBuilder->root('connection_parameters');
368
        $rootNode
369 8
            ->addDefaultsIfNotSet()
370 8
            ->children()
371 8
                ->scalarNode('scheme')->defaultValue('tcp')->end()
372 8
                ->scalarNode('host')->defaultNull()->end()
373 8
                ->integerNode('port')->defaultNull()->end()
374 8
                ->scalarNode('path')->defaultNull()->end()
375 8
                ->scalarNode('database')->defaultNull()->end()
376 8
                ->scalarNode('password')->defaultNull()->end()
377 8
                ->booleanNode('async')->defaultFalse()->end()
378 8
                ->booleanNode('persistent')->defaultFalse()->end()
379 8
                ->floatNode('timeout')->defaultValue(5.0)->end()
380 8
                ->floatNode('read_write_timeout')->defaultNull()->end()
381 8
                ->scalarNode('alias')->defaultNull()->end()
382 8
                ->integerNode('weight')->defaultNull()->end()
383 8
                ->booleanNode('iterable_multibulk')->defaultFalse()->end()
384 8
                ->booleanNode('throw_errors')->defaultTrue()->end()
385 8
            ->end()
386 View Code Duplication
            ->validate()->ifTrue(function ($node) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
387 1
                if (isset($node['host']) && !isset($node['port'])) {
388
                    return true;
389
                }
390 1
                if (isset($node['port']) && !isset($node['host'])) {
391
                    return true;
392
                }
393
394 1
                return false;
395 8
            })->thenInvalid('preids connection_parameters host and port should both be set')->end();
396
397 8
        return $rootNode;
398
    }
399
400 8
    protected function addRabbitMqOptions()
401
    {
402 8
        $treeBuilder = new TreeBuilder();
403 8
        $rootNode = $treeBuilder->root('options');
404
        $rootNode
405 8
            ->children()
406 8
                ->scalarNode('insist')->end()
407 8
                ->scalarNode('login_method')->end()
408 8
                ->scalarNode('login_response')->end()
409 8
                ->scalarNode('locale')->end()
410 8
                ->floatNode('connection_timeout')->end()
411 8
                ->floatNode('read_write_timeout')->end()
412 8
                ->booleanNode('keepalive')->end()
413 8
                ->integerNode('heartbeat')->end()
414 8
            ->end();
415
416 8
        return $rootNode;
417
    }
418
419 8
    protected function addRabbitMqSslOptions()
420
    {
421 8
        $treeBuilder = new TreeBuilder();
422 8
        $rootNode = $treeBuilder->root('ssl_options');
423
        $rootNode
424 8
            ->prototype('variable')->end()
425 8
            ->validate()
426
                ->ifTrue(function ($node) {
427 1
                    if (!is_array($node)) {
428
                        return true;
429
                    }
430 1
                    foreach ($node as $key => $value) {
431 1
                        if (is_array($value)) {
432 1
                            if ('peer_fingerprint' !== $key) {
433 1
                                return true;
434
                            } else {
435 1
                                foreach ($value as $key1 => $value1) {
436 1
                                    if (!is_string($key1) || !is_string($value1)) {
437
                                        return true;
438
                                    }
439 1
                                }
440
                            }
441 1
                        }
442 1
                    }
443
444 1
                    return false;
445 8
                })
446 8
                ->thenInvalid('Must be key-value pairs')
447 8
            ->end();
448
449 8
        return $rootNode;
450
    }
451
452 8 View Code Duplication
    protected function addRabbitMqExchange()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
453
    {
454 8
        $treeBuilder = new TreeBuilder();
455 8
        $rootNode = $treeBuilder->root('exchange_args');
456
        $rootNode
457 8
            ->addDefaultsIfNotSet()
458 8
            ->children()
459 8
                ->scalarNode('exchange')->defaultValue('dtc_queue_exchange')->end()
460 8
                ->booleanNode('type')->defaultValue('direct')->end()
461 8
                ->booleanNode('passive')->defaultFalse()->end()
462 8
                ->booleanNode('durable')->defaultTrue()->end()
463 8
                ->booleanNode('auto_delete')->defaultFalse()->end()
464 8
            ->end();
465
466 8
        return $rootNode;
467
    }
468
469 8 View Code Duplication
    protected function addRabbitMqArgs()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
470
    {
471 8
        $treeBuilder = new TreeBuilder();
472 8
        $rootNode = $treeBuilder->root('queue_args');
473
        $rootNode
474 8
            ->addDefaultsIfNotSet()
475 8
            ->children()
476 8
                ->scalarNode('queue')->defaultValue('dtc_queue')->end()
477 8
                ->booleanNode('passive')->defaultFalse()->end()
478 8
                ->booleanNode('durable')->defaultTrue()->end()
479 8
                ->booleanNode('exclusive')->defaultFalse()->end()
480 8
                ->booleanNode('auto_delete')->defaultFalse()->end()
481 8
            ->end();
482
483 8
        return $rootNode;
484
    }
485
486 8
    protected function addRabbitMq()
487
    {
488 8
        $treeBuilder = new TreeBuilder();
489 8
        $rootNode = $treeBuilder->root('rabbit_mq');
490
        $rootNode
491 8
            ->children()
492 8
                ->scalarNode('host')->end()
493 8
                ->scalarNode('port')->end()
494 8
                ->scalarNode('user')->end()
495 8
                ->scalarNode('password')->end()
496 8
                ->scalarNode('vhost')->defaultValue('/')->end()
497 8
                ->booleanNode('ssl')->defaultFalse()->end()
498 8
                ->append($this->addRabbitMqOptions())
499 8
                ->append($this->addRabbitMqSslOptions())
500 8
                ->append($this->addRabbitMqArgs())
501 8
                ->append($this->addRabbitMqExchange())
502 8
            ->end()
503
            ->validate()->always(function ($node) {
504 1
                if (empty($node['ssl_options'])) {
505 1
                    unset($node['ssl_options']);
506 1
                }
507 1
                if (empty($node['options'])) {
508 1
                    unset($node['options']);
509 1
                }
510
511 1
                return $node;
512 8
            })->end()
513 8
           ->validate()->ifTrue(function ($node) {
514 1
               if (isset($node['ssl_options']) && !$node['ssl']) {
515 1
                   return true;
516
               }
517
518 1
               return false;
519 8
           })->thenInvalid('ssl must be true in order to set ssl_options')->end()
520 8
        ->end();
521
522 8
        return $rootNode;
523
    }
524
}
525