Xclass   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 6
dl 0
loc 52
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareLoader() 0 27 4
A loadExtensionTables() 0 3 1
A loadExtensionConfiguration() 0 6 2
1
<?php
2
3
/**
4
 * Loading Xclass.
5
 */
6
declare(strict_types = 1);
7
8
namespace HDNET\Autoloader\Loader;
9
10
use HDNET\Autoloader\Loader;
11
use HDNET\Autoloader\LoaderInterface;
12
use HDNET\Autoloader\Utility\ClassNamingUtility;
13
use HDNET\Autoloader\Utility\ExtendedUtility;
14
use HDNET\Autoloader\Utility\FileUtility;
15
use HDNET\Autoloader\Utility\ReflectionUtility;
16
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
17
18
/**
19
 * Loading Xclass.
20
 */
21
class Xclass implements LoaderInterface
22
{
23
    /**
24
     * Get all the complex data for the loader.
25
     * This return value will be cached and stored in the database
26
     * There is no file monitoring for this cache.
27
     */
28
    public function prepareLoader(Loader $loader, int $type): array
29
    {
30
        $return = [];
31
        if (LoaderInterface::EXT_TABLES === $type) {
32
            return $return;
33
        }
34
        $xClassesPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Xclass/';
35
        $xClasses = FileUtility::getBaseFilesRecursivelyInDir($xClassesPath, 'php');
36
37
        foreach ($xClasses as $xClass) {
38
            $className = ClassNamingUtility::getFqnByPath(
39
                $loader->getVendorName(),
40
                $loader->getExtensionKey(),
41
                'Xclass/' . $xClass
42
            );
43
            if (!$loader->isInstantiableClass($className)) {
44
                continue;
45
            }
46
47
            $return[] = [
48
                'source' => ReflectionUtility::getParentClassName($className),
49
                'target' => $className,
50
            ];
51
        }
52
53
        return $return;
54
    }
55
56
    /**
57
     * Run the loading process for the ext_tables.php file.
58
     */
59
    public function loadExtensionTables(Loader $loader, array $loaderInformation): void
60
    {
61
    }
62
63
    /**
64
     * Run the loading process for the ext_localconf.php file.
65
     */
66
    public function loadExtensionConfiguration(Loader $loader, array $loaderInformation): void
67
    {
68
        foreach ($loaderInformation as $xclass) {
69
            ExtendedUtility::addXclass($xclass['source'], $xclass['target']);
70
        }
71
    }
72
}
73