Language::getTca()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 55

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 55
ccs 0
cts 9
cp 0
rs 8.9818
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * DataSet information for languages.
5
 */
6
declare(strict_types = 1);
7
8
namespace HDNET\Autoloader\DataSet;
9
10
use HDNET\Autoloader\DataSetInterface;
11
12
/**
13
 * DataSet information for languages.
14
 */
15
class Language implements DataSetInterface
16
{
17
    /**
18
     * Get TCA information.
19
     */
20
    public function getTca(string $tableName): array
21
    {
22
        return [
23
            'ctrl' => [
24
                'languageField' => 'sys_language_uid',
25
                'transOrigPointerField' => 'l10n_parent',
26
                'transOrigDiffSourceField' => 'l10n_diffsource',
27
            ],
28
            'columns' => [
29
                'sys_language_uid' => [
30
                    'exclude' => 1,
31
                    'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.language',
32
                    'config' => [
33
                        'type' => 'select',
34
                        'renderType' => 'selectSingle',
35
                        'default' => '0',
36
                        'special' => 'languages',
37
                        'items' => [
38
                            [
39
                                'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages',
40
                                -1,
41
                                'flags-multiple',
42
                            ],
43
                        ],
44
                    ],
45
                ],
46
                'l10n_parent' => [
47
                    'displayCond' => 'FIELD:sys_language_uid:>:0',
48
                    'exclude' => 1,
49
                    'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
50
                    'config' => [
51
                        'type' => 'select',
52
                        'renderType' => 'selectSingle',
53
                        'default' => 0,
54
                        'items' => [
55
                            [
56
                                '',
57
                                0,
58
                            ],
59
                        ],
60
                        'foreign_table' => $tableName,
61
                        'foreign_table_where' => 'AND ' . $tableName . '.pid=###CURRENT_PID### AND ' . $tableName . '.sys_language_uid IN (-1,0)',
62
                    ],
63
                ],
64
                'l10n_diffsource' => [
65
                    'config' => [
66
                        'type' => 'passthrough',
67
                    ],
68
                ],
69
            ],
70
            'palettes' => [
71
                'language' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource'],
72
            ],
73
        ];
74
    }
75
76
    /**
77
     * Get database sql information.
78
     */
79
    public function getDatabaseSql(string $tableName): array
80
    {
81
        return [
82
            'sys_language_uid int(11) DEFAULT \'0\' NOT NULL',
83
            'l10n_parent int(11) DEFAULT \'0\' NOT NULL',
84
            'l10n_diffsource mediumblob',
85
        ];
86
    }
87
88
    /**
89
     * Get database sql key information.
90
     */
91
    public function getDatabaseSqlKey(): array
92
    {
93
        return [
94
            'KEY language (l10n_parent,sys_language_uid)',
95
        ];
96
    }
97
}
98