Completed
Push — master ( 86437d...3559e6 )
by diego
08:58
created

FeatureRegistry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 22.22%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 21
ccs 2
cts 9
cp 0.2222
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A enable() 0 14 3
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * FeatureRegistry.php
6
 */
7
namespace HDNET\Importr\Feature;
8
9
use HDNET\Importr\Service\Manager;
10
use TYPO3\CMS\Core\Utility\GeneralUtility;
11
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
12
13
/**
14
 * Class FeatureRegistry
15
 */
16
class FeatureRegistry
17
{
18
    /**
19
     * @param string|array $names
20
     * @param string       $class
21
     */
22 4
    public static function enable($names, $class = Manager::class)
23
    {
24 4
        $dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
25
        if (!\is_array($names)) {
26
            $names = [$names];
27
        }
28
29
        $trace = \debug_backtrace(false, 2);
30
        $caller = $trace[1]['class'];
31
32
        foreach ($names as $name) {
33
            $dispatcher->connect($class, $name, $caller, 'execute');
34
        }
35
    }
36
}
37