Completed
Push — master ( 298ac7...0024da )
by Oleg
12:58
created

ConfigProvider::__invoke()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 149
Code Lines 92

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 149
ccs 0
cts 2
cp 0
rs 8.2857
c 0
b 0
f 0
cc 1
eloc 92
nc 1
nop 0
crap 2

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
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authentication;
5
6
use Doctrine\ORM\EntityManager;
7
use Psr\Log\LoggerInterface;
8
use SlayerBirden\DataFlowServer\Authentication\Controller\CreatePasswordAction;
9
use SlayerBirden\DataFlowServer\Authentication\Controller\GenerateTemporaryTokenAction;
10
use SlayerBirden\DataFlowServer\Authentication\Controller\GetTokenAction;
11
use SlayerBirden\DataFlowServer\Authentication\Controller\InvalidateTokenAction;
12
use SlayerBirden\DataFlowServer\Authentication\Factory\PasswordExtractionFactory;
13
use SlayerBirden\DataFlowServer\Authentication\Factory\TokenExtractionFactory;
14
use SlayerBirden\DataFlowServer\Authentication\Hydrator\PasswordHydrator;
15
use SlayerBirden\DataFlowServer\Authentication\Middleware\TokenMiddleware;
16
use SlayerBirden\DataFlowServer\Authentication\Middleware\TokenResourceMiddleware;
17
use SlayerBirden\DataFlowServer\Authentication\Service\PasswordManager;
18
use SlayerBirden\DataFlowServer\Authentication\Service\TokenManager;
19
use SlayerBirden\DataFlowServer\Authorization\PermissionManagerInterface;
20
use SlayerBirden\DataFlowServer\Zend\InputFilter\ProxyFilterManagerFactory;
21
use Zend\Expressive\Application;
22
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
23
24
class ConfigProvider
25
{
26
    public function __invoke(): array
27
    {
28
        return [
29
            ConfigAbstractFactory::class => [
30
                GenerateTemporaryTokenAction::class => [
31
                    EntityManager::class,
32
                    'TokenInputFilter',
33
                    TokenManagerInterface::class,
34
                    LoggerInterface::class,
35
                    'TokenExtraction',
36
                ],
37
                TokenMiddleware::class => [
38
                    EntityManager::class,
39
                ],
40
                PasswordManager::class => [
41
                    EntityManager::class,
42
                    LoggerInterface::class,
43
                ],
44
                TokenManager::class => [
45
                    PasswordManagerInterface::class,
46
                    EntityManager::class,
47
                    LoggerInterface::class,
48
                    PermissionManagerInterface::class,
49
                ],
50
                PasswordHydrator::class => [
51
                    PasswordManagerInterface::class,
52
                ],
53
                CreatePasswordAction::class => [
54
                    EntityManager::class,
55
                    'PasswordInputFilter',
56
                    LoggerInterface::class,
57
                    'PasswordExtraction',
58
                    PasswordHydrator::class,
59
                ],
60
                GetTokenAction::class => [
61
                    TokenManager::class,
62
                    'TokenExtraction',
63
                    'GetTokenInputFilter',
64
                ],
65
                InvalidateTokenAction::class => [
66
                    EntityManager::class,
67
                    LoggerInterface::class,
68
                    'TokenExtraction',
69
                ],
70
                TokenResourceMiddleware::class => [
71
                    EntityManager::class,
72
                    LoggerInterface::class,
73
                ],
74
            ],
75
            'doctrine' => [
76
                'paths' => [
77
                    'src/Authentication/Entities'
78
                ],
79
            ],
80
            'dependencies' => [
81
                'delegators' => [
82
                    Application::class => [
83
                        Factory\RoutesDelegator::class,
84
                    ],
85
                ],
86
                'factories' => [
87
                    'TokenExtraction' => TokenExtractionFactory::class,
88
                    'PasswordExtraction' => PasswordExtractionFactory::class,
89
                    'TokenInputFilter' => ProxyFilterManagerFactory::class,
90
                    'PasswordInputFilter' => ProxyFilterManagerFactory::class,
91
                    'UpdatePasswordInputFilter' => ProxyFilterManagerFactory::class,
92
                    'GetTokenInputFilter' => ProxyFilterManagerFactory::class,
93
                ],
94
                'aliases' => [
95
                    TokenManagerInterface::class => TokenManager::class,
96
                    PasswordManagerInterface::class => PasswordManager::class,
97
                ],
98
            ],
99
            'input_filter_specs' => [
100
                'TokenInputFilter' => [
101
                    'resources' => [
102
                        'required' => true,
103
                        'filters' => [
104
                            [
105
                                'name' => 'stringtrim',
106
                            ]
107
                        ],
108
                        'validators' => [
109
                            [
110
                                'name' => 'resourcesValidator',
111
                            ],
112
                        ],
113
                    ],
114
                ],
115
                'PasswordInputFilter' => [
116
                    'password' => [
117
                        'required' => true,
118
                        'validators' => [
119
                            [
120
                                'name' => 'stringLength',
121
                                'options' => [
122
                                    'min' => 10,
123
                                ],
124
                            ],
125
                        ],
126
                    ],
127
                ],
128
                'UpdatePasswordInputFilter' => [
129
                    'new_password' => [
130
                        'required' => true,
131
                        'validators' => [
132
                            [
133
                                'name' => 'stringLength',
134
                                'options' => [
135
                                    'min' => 10,
136
                                ],
137
                            ],
138
                        ],
139
                    ],
140
                ],
141
                'GetTokenInputFilter' => [
142
                    'resources' => [
143
                        'required' => true,
144
                        'filters' => [
145
                            [
146
                                'name' => 'stringtrim',
147
                            ]
148
                        ],
149
                        'validators' => [
150
                            [
151
                                'name' => 'resourcesValidator',
152
                            ],
153
                        ],
154
                    ],
155
                    'password' => [
156
                        'required' => true,
157
                        'validators' => [
158
                            [
159
                                'name' => 'notempty',
160
                            ],
161
                        ]
162
                    ],
163
                    'user' => [
164
                        'required' => true,
165
                        'validators' => [
166
                            [
167
                                'name' => 'notempty',
168
                            ],
169
                        ]
170
                    ],
171
                ],
172
            ],
173
        ];
174
    }
175
}
176