Completed
Pull Request — master (#30)
by Matthew
16:41
created

Configuration::addRedis()   C

Complexity

Conditions 21
Paths 1

Size

Total Lines 63
Code Lines 51

Duplication

Lines 19
Ratio 30.16 %

Code Coverage

Tests 0
CRAP Score 462

Importance

Changes 0
Metric Value
dl 19
loc 63
ccs 0
cts 0
cp 0
rs 5.9794
c 0
b 0
f 0
cc 21
eloc 51
nc 1
nop 0
crap 462

How to fix   Long Method    Complexity   

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 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 4
     */
17
    public function getConfigTreeBuilder()
18 4
    {
19 4
        if (Kernel::VERSION_ID < 30400) {
20
            return $this->getConfigTreeBuilderSymfony2();
21
        }
22 4
23 4
        $treeBuilder = new TreeBuilder();
24 4
        $rootNode = $treeBuilder->root('dtc_queue');
25 4
26 4
        $rootNode
27 4
            ->children()
28 4
                ->append($this->addOrm())
29 4
                ->append($this->addOdm())
30 4
                ->append($this->addManager())
31 4
                ->append($this->addTimings())
32 4
                ->append($this->addBeanstalkd())
33 4
                ->append($this->addRabbitMq())
34 4
                ->append($this->addRedis())
35 4
                ->append($this->addAdmin())
36 4
                ->append($this->addClasses())
37 4
                ->append($this->addPriority())
38 4
                ->append($this->addRetry())
39 4
                ->scalarNode('document_manager')->setDeprecated('The "%node% option is deprecated, Use "odm: { document_manager: ... }" instead.')->end()
40 4
                ->scalarNode('entity_manager')->setDeprecated('The "%node% option is deprecated, Use "odm: { entity_manager: ... }" instead.')->end()
41 4
                ->scalarNode('default_manager')->setDeprecated('The "%node% option is deprecated, Use "manager: { job: ... }" instead.')->end()
42 4
                ->scalarNode('run_manager')->setDeprecated('The "%node% option is deprecated, Use "manager: { run: ... }" instead.')->end()
43 4
                ->scalarNode('job_timing_manager')->setDeprecated('The "%node% option is deprecated, Use "manager: { job_timing: ... }" instead.')->end()
44 4
                ->booleanNode('record_timings')->setDeprecated('The "%node% option is deprecated, Use "timings: { record: ... }" instead.')->end()
45 4
                ->integerNode('record_timings_timezone_offset')->setDeprecated('The "%node% option is deprecated, Use "record: { timezone_offset: ... }" instead.')->end()
46 4
                ->scalarNode('class_job')->setDeprecated('The "%node% option is deprecated, Use "class: { job: ... }" instead.')->end()
47 4
                ->scalarNode('class_job_archive')->setDeprecated('The "%node% option is deprecated, Use "class: { job_archive: ... }" instead.')->end()
48 4
                ->scalarNode('class_run')->setDeprecated('The "%node% option is deprecated, Use "class: { run: ... }" instead.')->end()
49 4
                ->scalarNode('class_run_archive')->setDeprecated('The "%node% option is deprecated, Use "class: { run_archive: ... }" instead.')->end()
50 4
                ->scalarNode('class_job_timing')->setDeprecated('The "%node% option is deprecated, Use "class: { job_timing: ... }" instead.')->end()
51 4
                ->scalarNode('priority_max')->setDeprecated('The "%node% option is deprecated, Use "priority: { max: ... }" instead.')->end()
52 4
                ->scalarNode('priority_direction')->setDeprecated('The "%node% option is deprecated, Use "priority: { direction: ... }" instead.')->end()
53 4
            ->end();
54 4
55 4
        return $treeBuilder;
56 4
    }
57 4
58 4
    public function getConfigTreeBuilderSymfony2()
59 4
    {
60 4
        $treeBuilder = new TreeBuilder();
61 4
        $rootNode = $treeBuilder->root('dtc_queue');
62 4
63 4
        $rootNode
64 4
            ->children()
65 4
            ->append($this->addOrm())
66 4
            ->append($this->addOdm())
67 4
            ->append($this->addManager())
68 4
            ->append($this->addTimings())
69 4
            ->append($this->addBeanstalkd())
70 4
            ->append($this->addRabbitMq())
71 4
            ->append($this->addRedis())
72
            ->append($this->addAdmin())
73 4
            ->append($this->addClasses())
74
            ->append($this->addPriority())
75
            ->append($this->addRetry())
76 4
            ->scalarNode('document_manager')->end()
77
            ->scalarNode('entity_manager')->end()
78 4
            ->scalarNode('default_manager')->end()
79 4
            ->scalarNode('run_manager')->end()
80
            ->scalarNode('job_timing_manager')->end()
81 4
            ->booleanNode('record_timings')->end()
82 4
            ->integerNode('record_timings_timezone_offset')->end()
83 4
            ->scalarNode('class_job')->end()
84 4
            ->scalarNode('class_job_archive')->end()
85
            ->scalarNode('class_run')->end()
86 4
            ->scalarNode('class_run_archive')->end()
87
            ->scalarNode('class_job_timing')->end()
88
            ->scalarNode('priority_max')->end()
89 4
            ->scalarNode('priority_direction')->end()
90
            ->end();
91 4
92 4
        return $treeBuilder;
93
    }
94 4
95 4
    protected function addTimings()
96 4
    {
97 4
        $treeBuilder = new TreeBuilder();
98 4
        $rootNode = $treeBuilder->root('timings');
99 4
        $rootNode
100 4
            ->addDefaultsIfNotSet()
101 4
            ->children()
102 4
                ->booleanNode('record')
103 4
                    ->info('Set this to true to record timings (used on the Trends page)')
104
                    ->defaultFalse()
105 4
                ->end()
106
                ->floatNode('timezone_offset')
107
                    ->defaultValue(0)
108 4
                    ->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')
109
                    ->max(24)
110 4
                    ->min(-24)
111 4
                ->end()
112
            ->end();
113 4
114 4
        return $rootNode;
115 4
    }
116 1
117 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...
118
    {
119 1
        $treeBuilder = new TreeBuilder();
120 1
        $rootNode = $treeBuilder->root('orm');
121 1
        $rootNode
122 1
            ->addDefaultsIfNotSet()
123
            ->children()
124 1
                ->scalarNode('entity_manager')
125 1
                    ->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')
126 1
                    ->defaultValue('default')
127
                    ->cannotBeEmpty()
128
                ->end()
129
            ->end();
130
131
        return $rootNode;
132
    }
133 1
134 4 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...
135 4
    {
136 4
        $treeBuilder = new TreeBuilder();
137
        $rootNode = $treeBuilder->root('odm');
138 4
        $rootNode
139
            ->addDefaultsIfNotSet()
140
            ->children()
141 4
                ->scalarNode('document_manager')
142
                    ->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')
143 4
                    ->defaultValue('default')
144 4
                    ->cannotBeEmpty()
145
                ->end()
146 4
            ->end();
147 4
148 4
        return $rootNode;
149 4
    }
150 4
151 4
    protected function addManager()
152 4
    {
153 4
        $treeBuilder = new TreeBuilder();
154
        $rootNode = $treeBuilder->root('manager');
155 4
        $rootNode
156
            ->addDefaultsIfNotSet()
157
            ->children()
158 4
                ->scalarNode('job')
159
                    ->defaultValue('odm')
160 4
                    ->info('This can be [odm|orm|beanstalkd|rabbit_mq|redis|(your-own-custom-one)]')
161 4
                    ->cannotBeEmpty()
162
                ->end()
163 4
                ->scalarNode('run')->end()
164 4
                ->scalarNode('job_timing')->end()
165 4
            ->end();
166 4
167 4
        return $rootNode;
168 4
    }
169 4
170 4
    protected function addBeanstalkd()
171
    {
172 4
        $treeBuilder = new TreeBuilder();
173
        $rootNode = $treeBuilder->root('beanstalkd');
174
        $rootNode
175 4
            ->children()
176
                ->scalarNode('host')->end()
177 4
                ->scalarNode('tube')->end()
178 4
            ->end();
179
180 4
        return $rootNode;
181 4
    }
182 4
183 4
    protected function addRetry()
184 4
    {
185 4
        $treeBuilder = new TreeBuilder();
186 4
        $rootNode = $treeBuilder->root('retry');
187 4
        $rootNode
188 4
            ->addDefaultsIfNotSet()
189 4
            ->children()
190 4
                ->arrayNode('max')
191 4
                    ->addDefaultsIfNotSet()
192 4
                    ->children()
193 1
                        ->integerNode('retries')
194 1
                            ->info('This the maximum total number of retries of any type.')
195
                            ->defaultValue(3)
196 1
                        ->end()
197 1
                        ->integerNode('failures')
198
                            ->info('This the maximum total number of failures before a job is marked as hitting the maximum failures.')
199
                            ->defaultValue(1)
200 1
                        ->end()
201 4
                        ->integerNode('exceptions')
202 4
                            ->info('This the maximum total number of exceptions before a job is marked as hitting the maximum exceptions.')
203 1
                            ->defaultValue(2)
204 1
                        ->end()
205
                        ->integerNode('stalls')
206
                            ->info('This the maximum total number of exceptions before a job is marked as hitting the maximum exceptions.')
207 1
                            ->defaultValue(2)
208 4
                        ->end()
209
                    ->end()
210
                ->end()
211
                ->arrayNode('auto')
212
                    ->addDefaultsIfNotSet()
213
                    ->children()
214
                        ->booleanNode('failure')
215
                            ->info('Instantly re-queue the job on failure.')
216
                            ->defaultTrue()
217
                        ->end()
218
                        ->booleanNode('exception')
219
                            ->info('Instantly re-queue the job on exception.')
220
                            ->defaultFalse()
221
                        ->end()
222
                    ->end()
223
                ->end()
224
            ->end();
225
226
        return $rootNode;
227
    }
228
229
    protected function addPriority()
230
    {
231
        $treeBuilder = new TreeBuilder();
232
        $rootNode = $treeBuilder->root('priority');
233
        $rootNode
234
            ->addDefaultsIfNotSet()
235
            ->children()
236
                ->integerNode('max')
237
                    ->defaultValue(255)
238
                    ->info('Maximum priority value.')
239
                    ->min(1)
240
                ->end()
241
                ->enumNode('direction')
242
                    ->values([PriorityJobManager::PRIORITY_ASC, PriorityJobManager::PRIORITY_DESC])
243
                    ->info('Whether 1 is high priority or low prioirty.  '.PriorityJobManager::PRIORITY_ASC.' means 1 is low, '.PriorityJobManager::PRIORITY_DESC.' means 1 is high.')
244
                    ->defaultValue(PriorityJobManager::PRIORITY_DESC)
245
                ->end()
246
            ->end();
247
248
        return $rootNode;
249
    }
250
251
    protected function addClasses()
252
    {
253
        $treeBuilder = new TreeBuilder();
254
        $rootNode = $treeBuilder->root('class');
255
        $rootNode
256
            ->children()
257
                ->scalarNode('job')
258
                    ->info('If you want to override the Job class, put the class name here.')->end()
259
                ->scalarNode('job_archive')
260
                    ->info('If you want to override the JobArchive class, put the class name here.')->end()
261
                ->scalarNode('job_timing')
262
                    ->info('If you want to override the JobTiming class, put the class name here.')->end()
263
                ->scalarNode('run')
264
                    ->info('If you want to override the Run class, put the class name here.')->end()
265
                ->scalarNode('run_archive')
266
                    ->info('If you want to override the RunArchive class, put the class name here.')->end()
267
            ->end();
268
269
        return $rootNode;
270
    }
271
272 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...
273
    {
274
        $treeBuilder = new TreeBuilder();
275
        $rootNode = $treeBuilder->root('admin');
276
        $rootNode
277
            ->addDefaultsIfNotSet()
278
            ->children()
279
                ->scalarNode('chartjs')
280
                    ->defaultValue('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.bundle.min.js')
281
                    ->info('This can be changed to say a locally hosted path or url.')->end()
282
                ->end()
283
            ->end();
284
285
        return $rootNode;
286
    }
287
288
    protected function addRedis()
289
    {
290
        $treeBuilder = new TreeBuilder();
291
        $rootNode = $treeBuilder->root('redis');
292
        $rootNode
293
            ->addDefaultsIfNotSet()
294
            ->children()
295
                ->scalarNode('prefix')->defaultValue('dtc_queue_')->end()
296
                ->arrayNode('snc_redis')
297
                    ->children()
298
                        ->enumNode('type')
299
                            ->values(['predis', 'phpredis'])
300
                            ->defaultNull()->end()
301
                        ->scalarNode('alias')
302
                            ->defaultNull()->end()
303
                    ->end()
304 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...
305
                        if (isset($node['type']) && !isset($node['alias'])) {
306
                            return false;
307
                        }
308
                        if (isset($node['alias']) && !isset($node['type'])) {
309
                            return false;
310
                        }
311
312
                        return true;
313
                    })->thenInvalid('if alias or type is set, then both must be set')->end()
314
                ->end()
315
                ->arrayNode('predis')
316
                    ->children()
317
                        ->scalarNode('dsn')->defaultNull()->end()
318
                        ->append($this->addPredisArgs())
319
                    ->end()
320
                    ->validate()->ifTrue(function ($node) {
321
                        if (isset($node['dsn']) && (isset($node['connection_parameters']['host']) || isset($node['connection_parameters']['port']))) {
322
                            return false;
323
                        }
324
325
                        return true;
326
                    })->thenInvalid('if dsn is set, do not use connection_parameters for predis (and vice-versa)')->end()
327
                ->end()
328
                ->append($this->addPhpRedisArgs())
329
            ->end()
330
            ->validate()->ifTrue(function ($node) {
331 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...
332
                    (isset($node['snc_redis']['type']) || isset($node['phpredis']['host']))) {
333
                    return false;
334
                }
335 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...
336
                    (isset($node['predis']['dsn']) || isset($node['predis']['connection_parameters']['host']) ||
337
                    isset($node['phpredis']['host']))) {
338
                    return false;
339
                }
340
                if ((isset($node['phpredis']['host']) || isset($node['phpredis']['port'])) &&
341
                    (isset($node['snc_redis']['type']) || isset($node['predis']['dsn']) ||
342
                     isset($node['predis']['connection_parameters']['host']))) {
343
                    return false;
344
                }
345
346
                return true;
347
            })->thenInvalid('only one of [snc_redis | predis | phpredis] should be set')->end();
348
349
        return $rootNode;
350
    }
351
352
    protected function addPhpRedisArgs()
353
    {
354
        $treeBuilder = new TreeBuilder();
355
        $rootNode = $treeBuilder->root('php_redis');
356
        $rootNode
357
            ->children()
358
                ->scalarNode('host')->end()
359
                ->integerNode('port')->defaultValue(6379)->end()
360
                ->floatNode('timeout')->defaultValue(0)->end()
361
                ->integerNode('retry_interval')->defaultNull()->end()
362
                ->floatNode('read_timeout')->defaultValue(0)->end()
363
                ->scalarNode('auth')->end()
364
            ->end()
365
            ->validate()->ifTrue(function ($node) {
366
                if (!empty($node) && !isset($node['host'])) {
367
                    return false;
368
                }
369
370
                return true;
371
            })->thenInvalid('phpredis host should be set')->end();
372
373
        return $rootNode;
374
    }
375
376
    protected function addPredisArgs()
377
    {
378
        $treeBuilder = new TreeBuilder();
379
        $rootNode = $treeBuilder->root('connection_parameters');
380
        $rootNode
381
            ->addDefaultsIfNotSet()
382
            ->children()
383
                ->scalarNode('scheme')->defaultValue('tcp')->end()
384
                ->scalarNode('host')->defaultNull()->end()
385
                ->integerNode('port')->defaultNull()->end()
386
                ->scalarNode('path')->defaultNull()->end()
387
                ->scalarNode('database')->defaultNull()->end()
388
                ->scalarNode('password')->defaultNull()->end()
389
                ->booleanNode('async')->defaultFalse()->end()
390
                ->booleanNode('persistent')->defaultFalse()->end()
391
                ->floatNode('timeout')->defaultValue(5.0)->end()
392
                ->floatNode('read_write_timeout')->defaultNull()->end()
393
                ->scalarNode('alias')->defaultNull()->end()
394
                ->integerNode('weight')->defaultNull()->end()
395
                ->booleanNode('iterable_multibulk')->defaultFalse()->end()
396
                ->booleanNode('throw_errors')->defaultTrue()->end()
397
            ->end()
398 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...
399
                if (isset($node['host']) && !isset($node['port'])) {
400
                    return false;
401
                }
402
                if (isset($node['port']) && !isset($node['host'])) {
403
                    return false;
404
                }
405
406
                return true;
407
            })->thenInvalid('preids connection_parameters host and port should both be set')->end();
408
409
        return $rootNode;
410
    }
411
412
    protected function addRabbitMqOptions()
413
    {
414
        $treeBuilder = new TreeBuilder();
415
        $rootNode = $treeBuilder->root('options');
416
        $rootNode
417
            ->children()
418
                ->scalarNode('insist')->end()
419
                ->scalarNode('login_method')->end()
420
                ->scalarNode('login_response')->end()
421
                ->scalarNode('locale')->end()
422
                ->floatNode('connection_timeout')->end()
423
                ->floatNode('read_write_timeout')->end()
424
                ->booleanNode('keepalive')->end()
425
                ->integerNode('heartbeat')->end()
426
            ->end();
427
428
        return $rootNode;
429
    }
430
431
    protected function addRabbitMqSslOptions()
432
    {
433
        $treeBuilder = new TreeBuilder();
434
        $rootNode = $treeBuilder->root('ssl_options');
435
        $rootNode
436
            ->prototype('variable')->end()
437
            ->validate()
438
                ->ifTrue(function ($node) {
439
                    if (!is_array($node)) {
440
                        return true;
441
                    }
442
                    foreach ($node as $key => $value) {
443
                        if (is_array($value)) {
444
                            if ('peer_fingerprint' !== $key) {
445
                                return true;
446
                            } else {
447
                                foreach ($value as $key1 => $value1) {
448
                                    if (!is_string($key1) || !is_string($value1)) {
449
                                        return true;
450
                                    }
451
                                }
452
                            }
453
                        }
454
                    }
455
456
                    return false;
457
                })
458
                ->thenInvalid('Must be key-value pairs')
459
            ->end();
460
461
        return $rootNode;
462
    }
463
464 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...
465
    {
466
        $treeBuilder = new TreeBuilder();
467
        $rootNode = $treeBuilder->root('exchange_args');
468
        $rootNode
469
            ->addDefaultsIfNotSet()
470
            ->children()
471
                ->scalarNode('exchange')->defaultValue('dtc_queue_exchange')->end()
472
                ->booleanNode('type')->defaultValue('direct')->end()
473
                ->booleanNode('passive')->defaultFalse()->end()
474
                ->booleanNode('durable')->defaultTrue()->end()
475
                ->booleanNode('auto_delete')->defaultFalse()->end()
476
            ->end();
477
478
        return $rootNode;
479
    }
480
481 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...
482
    {
483
        $treeBuilder = new TreeBuilder();
484
        $rootNode = $treeBuilder->root('queue_args');
485
        $rootNode
486
            ->addDefaultsIfNotSet()
487
            ->children()
488
                ->scalarNode('queue')->defaultValue('dtc_queue')->end()
489
                ->booleanNode('passive')->defaultFalse()->end()
490
                ->booleanNode('durable')->defaultTrue()->end()
491
                ->booleanNode('exclusive')->defaultFalse()->end()
492
                ->booleanNode('auto_delete')->defaultFalse()->end()
493
            ->end();
494
495
        return $rootNode;
496
    }
497
498
    protected function addRabbitMq()
499
    {
500
        $treeBuilder = new TreeBuilder();
501
        $rootNode = $treeBuilder->root('rabbit_mq');
502
        $rootNode
503
            ->children()
504
                ->scalarNode('host')->end()
505
                ->scalarNode('port')->end()
506
                ->scalarNode('user')->end()
507
                ->scalarNode('password')->end()
508
                ->scalarNode('vhost')->defaultValue('/')->end()
509
                ->booleanNode('ssl')->defaultFalse()->end()
510
                ->append($this->addRabbitMqOptions())
511
                ->append($this->addRabbitMqSslOptions())
512
                ->append($this->addRabbitMqArgs())
513
                ->append($this->addRabbitMqExchange())
514
            ->end()
515
            ->validate()->always(function ($node) {
516
                if (empty($node['ssl_options'])) {
517
                    unset($node['ssl_options']);
518
                }
519
                if (empty($node['options'])) {
520
                    unset($node['options']);
521
                }
522
                return $node;
523
            })->end()
524
           ->validate()->ifTrue(function ($node) {
525
               if (isset($node['ssl_options']) && !$node['ssl']) {
526
                   return true;
527
               }
528
529
               return false;
530
           })->thenInvalid('ssl must be true in order to set ssl_options')->end()
531
        ->end();
532
533
        return $rootNode;
534
    }
535
}
536