Completed
Push — master ( 00f053...d31cc1 )
by diego
02:44
created

FeatureRegistry::enable()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 8
nc 4
nop 2
crap 3
1
<?php
2
/**
3
 * FeatureRegistry.php
4
 */
5
namespace HDNET\Importr\Feature;
6
7
use HDNET\Importr\Service\Manager;
8
use TYPO3\CMS\Core\Utility\GeneralUtility;
9
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
10
11
/**
12
 * Class FeatureRegistry
13
 */
14
class FeatureRegistry
15
{
16
    /**
17
     * @param string|array $names
18
     * @param string $class
19
     */
20 3
    public static function enable($names, $class = Manager::class)
21
    {
22 3
        $dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
23 3
        if (!is_array($names)) {
24 3
            $names = [$names];
25
        }
26
27 3
        $trace = debug_backtrace(false, 2);
28 3
        $caller = $trace[1]['class'];
29
30 3
        foreach ($names as $name) {
31 3
            $dispatcher->connect($class, $name, $caller, 'execute');
32
        }
33 3
    }
34
}
35