InvokableTranslator::process()   B
last analyzed

Complexity

Conditions 7
Paths 5

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 7.0178

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 15
c 2
b 0
f 1
dl 0
loc 25
ccs 13
cts 14
cp 0.9286
rs 8.8333
cc 7
nc 5
nop 1
crap 7.0178
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\SymfonyConfigTranslator;
6
7
class InvokableTranslator
8
{
9
10 5
    public function process(array &$symfonyService): array
11
    {
12 5
        $invokables = [];
13
14 5
        foreach ($symfonyService as $name => $service) {
15 5
            if (is_array($service) && array_key_exists('factory', $service)) {
16
                continue;
17
            }
18
19 5
            if (empty($service)) {
20 1
                $invokables[$name] = $name;
21 1
                unset($symfonyService[$name]);
22 1
                continue;
23
            }
24
25 5
            if (empty($service['arguments']) && isset($service['class'])) {
26 2
                $invokables[$name] = $service['class'];
27 2
                unset($symfonyService[$name]);
28 2
                continue;
29
            }
30
        }
31
32
        return [
33
            'dependencies' => [
34 5
                'services' => $invokables,
35
            ],
36
        ];
37
    }
38
}
39