Completed
Push — master ( bcd471...c4f4ce )
by Joschi
02:58
created

configureDateActionDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 63
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 38
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 63
ccs 38
cts 38
cp 1
rs 9.4347
cc 1
eloc 37
nc 1
nop 1
crap 1

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
/**
4
 * apparat-server
5
 *
6
 * @category    Apparat
7
 * @package     Apparat\Server
8
 * @subpackage  Apparat\Server\Infrastructure
9
 * @author      Joschi Kuphal <[email protected]> / @jkphl
10
 * @copyright   Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
11
 * @license     http://opensource.org/licenses/MIT The MIT License (MIT)
12
 */
13
14
/***********************************************************************************
15
 *  The MIT License (MIT)
16
 *
17
 *  Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
18
 *
19
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of
20
 *  this software and associated documentation files (the "Software"), to deal in
21
 *  the Software without restriction, including without limitation the rights to
22
 *  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23
 *  the Software, and to permit persons to whom the Software is furnished to do so,
24
 *  subject to the following conditions:
25
 *
26
 *  The above copyright notice and this permission notice shall be included in all
27
 *  copies or substantial portions of the Software.
28
 *
29
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
 ***********************************************************************************/
36
37
namespace Apparat\Server\Infrastructure\Traits;
38
39
use Apparat\Kernel\Ports\Contract\DependencyInjectionContainerInterface;
40
use Apparat\Server\Domain\Contract\ResponderInterface;
41
use Apparat\Server\Domain\Service\ServiceInterface;
42
use Apparat\Server\Infrastructure\Action\DayAction;
43
use Apparat\Server\Infrastructure\Action\HourAction;
44
use Apparat\Server\Infrastructure\Action\MinuteAction;
45
use Apparat\Server\Infrastructure\Action\MonthAction;
46
use Apparat\Server\Infrastructure\Action\SecondAction;
47
use Apparat\Server\Infrastructure\Action\YearAction;
48
use Apparat\Server\Infrastructure\Responder\DayResponder;
49
use Apparat\Server\Infrastructure\Responder\HourResponder;
50
use Apparat\Server\Infrastructure\Responder\MinuteResponder;
51
use Apparat\Server\Infrastructure\Responder\MonthResponder;
52
use Apparat\Server\Infrastructure\Responder\SecondResponder;
53
use Apparat\Server\Infrastructure\Responder\YearResponder;
54
use Apparat\Server\Infrastructure\Service\DayService;
55
use Apparat\Server\Infrastructure\Service\HourService;
56
use Apparat\Server\Infrastructure\Service\MinuteService;
57
use Apparat\Server\Infrastructure\Service\MonthService;
58
use Apparat\Server\Infrastructure\Service\SecondService;
59
use Apparat\Server\Infrastructure\Service\YearService;
60
61
/**
62
 * Date actions trait
63
 *
64
 * @package Apparat\Server
65
 * @subpackage Apparat\Server\Infrastructure
66
 */
67
trait DateActionsTrait
68
{
69
    /**
70
     * Configure the action dependencies
71
     *
72
     * @param DependencyInjectionContainerInterface $diContainer Dependency injection container
73
     */
74 1
    protected function configureDateActionDependencies(DependencyInjectionContainerInterface $diContainer)
75
    {
76 1
        $diContainer->register(YearAction::class, [
77
            'substitutions' => [
78
                ServiceInterface::class => [
79 1
                    'instance' => YearService::class,
80 1
                ],
81
                ResponderInterface::class => [
82 1
                    'instance' => YearResponder::class,
83
                ]
84 1
            ]
85 1
        ]);
86 1
        $diContainer->register(MonthAction::class, [
87
            'substitutions' => [
88
                ServiceInterface::class => [
89 1
                    'instance' => MonthService::class,
90 1
                ],
91
                ResponderInterface::class => [
92 1
                    'instance' => MonthResponder::class,
93
                ]
94 1
            ]
95 1
        ]);
96 1
        $diContainer->register(DayAction::class, [
97
            'substitutions' => [
98
                ServiceInterface::class => [
99 1
                    'instance' => DayService::class,
100 1
                ],
101
                ResponderInterface::class => [
102 1
                    'instance' => DayResponder::class,
103
                ]
104 1
            ]
105 1
        ]);
106 1
        $diContainer->register(HourAction::class, [
107
            'substitutions' => [
108
                ServiceInterface::class => [
109 1
                    'instance' => HourService::class,
110 1
                ],
111
                ResponderInterface::class => [
112 1
                    'instance' => HourResponder::class,
113
                ]
114 1
            ]
115 1
        ]);
116 1
        $diContainer->register(MinuteAction::class, [
117
            'substitutions' => [
118
                ServiceInterface::class => [
119 1
                    'instance' => MinuteService::class,
120 1
                ],
121
                ResponderInterface::class => [
122 1
                    'instance' => MinuteResponder::class,
123
                ]
124 1
            ]
125 1
        ]);
126 1
        $diContainer->register(SecondAction::class, [
127
            'substitutions' => [
128
                ServiceInterface::class => [
129 1
                    'instance' => SecondService::class,
130 1
                ],
131
                ResponderInterface::class => [
132 1
                    'instance' => SecondResponder::class,
133
                ]
134 1
            ]
135 1
        ]);
136 1
    }
137
}
138