DateTimeMapper::getDatabaseDefinition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * Map DateTime.
5
 */
6
declare(strict_types = 1);
7
8
namespace HDNET\Autoloader\Mapper;
9
10
use HDNET\Autoloader\MapperInterface;
11
12
/**
13
 * Map DateTime.
14
 */
15
class DateTimeMapper implements MapperInterface
16
{
17
    /**
18
     * Check if the current mapper can handle the given type.
19
     *
20
     * @param string $type
21
     *
22
     * @return bool
23
     */
24
    public function canHandleType($type)
25
    {
26
        return \in_array(mb_strtolower(trim($type, '\\')), [
27
            'datetime',
28
        ], true);
29
    }
30
31
    /**
32
     * Get the TCA configuration for the current type.
33
     *
34
     * @param string $fieldName
35
     * @param bool   $overWriteLabel
36
     *
37
     * @return array
38
     */
39
    public function getTcaConfiguration($fieldName, $overWriteLabel = false)
40
    {
41
        return [
42
            'exclude' => 1,
43
            'label' => $overWriteLabel ? $overWriteLabel : $fieldName,
44
            'config' => [
45
                'type' => 'input',
46
                'renderType' => 'inputDateTime',
47
                'eval' => 'datetime',
48
                'size' => 8,
49
            ],
50
        ];
51
    }
52
53
    /**
54
     * Get the database definition for the current mapper.
55
     *
56
     * @return string
57
     */
58
    public function getDatabaseDefinition()
59
    {
60
        return 'int(11) DEFAULT \'0\' NOT NULL';
61
    }
62
}
63