TcaUtility   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 29
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A insertTabDividerBefore() 0 15 3
1
<?php
2
3
/**
4
 * TcaUtility.php.
5
 *
6
 * General file information
7
 */
8
declare(strict_types = 1);
9
10
namespace HDNET\Autoloader\Utility;
11
12
use HDNET\Autoloader\Exception;
13
14
/**
15
 * A basic TCA manipulation utility class.
16
 */
17
class TcaUtility
18
{
19
    /**
20
     * Inserts a divider tab before a given column name.
21
     *
22
     * @param array  $base       The base TCA array
23
     * @param string $columnName The column name before to insert a tab divider
24
     * @param string $tabTitle   The title of the tab
25
     *
26
     * @throws Exception
27
     *
28
     * @return array
29
     */
30
    public static function insertTabDividerBefore(&$base, $columnName, $tabTitle)
31
    {
32
        if (!\is_array($base)) {
33
            throw new Exception('A proper TCA configuration is needed!', 17823492);
34
        }
35
36
        $divider = '--div--;' . $tabTitle . ',';
37
        foreach ($base['types'] as $key => $layout) {
38
            $tempShowitem = explode($columnName, $layout['showitem']);
39
            $showItem = $tempShowitem[0] . $divider . $columnName . $tempShowitem[1];
40
            $base['types'][$key]['showitem'] = $showItem;
41
        }
42
43
        return $base;
44
    }
45
}
46