Database   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
c 4
b 0
f 0
lcom 0
cbo 1
dl 0
loc 56
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loadTables() 0 5 1
A updateTables() 0 8 1
A getDatabaseString() 0 11 2
1
<?php
2
/**
3
 * Database
4
 */
5
6
namespace HDNET\Tagger\Slots;
7
8
use HDNET\Tagger\Utility\TaggerRegister;
9
10
/**
11
 * Database
12
 */
13
class Database
14
{
15
16
    /**
17
     * Add the smart object SQL string the the signal below
18
     *
19
     * @signalClass \TYPO3\CMS\Install\Service\SqlExpectedSchemaService
20
     * @signalName tablesDefinitionIsBeingBuilt
21
     *
22
     * @param array $sqlString
23
     *
24
     * @return array
25
     */
26
    public function loadTables(array $sqlString)
27
    {
28
        $sqlString[] = $this->getDatabaseString();
29
        return ['sqlString' => $sqlString];
30
    }
31
32
    /**
33
     * Add the smart object SQL string the the signal below
34
     *
35
     * @signalClass \TYPO3\CMS\Extensionmanager\Utility\InstallUtility
36
     * @signalName tablesDefinitionIsBeingBuilt
37
     *
38
     * @param array $sqlString
39
     * @param string $extensionKey
40
     *
41
     * @return array
42
     */
43
    public function updateTables(array $sqlString, $extensionKey)
44
    {
45
        $sqlString[] = $this->getDatabaseString();
46
        return [
47
            'sqlString' => $sqlString,
48
            'extensionKey' => $extensionKey
49
        ];
50
    }
51
52
    /**
53
     * Get the tagger string for the registered tables
54
     *
55
     * @return string
56
     */
57
    protected function getDatabaseString()
58
    {
59
        $sql = [];
60
        foreach (TaggerRegister::getRegister() as $configuration) {
61
            $table = $configuration['tableName'];
62
            $sql[] = 'CREATE TABLE ' . $table . ' (
63
			tagger tinytext
64
			);';
65
        }
66
        return implode(LF, $sql);
67
    }
68
}
69