Completed
Push — master ( d82c34...7d95c1 )
by Tim
20:17 queued 05:19
created

ModelMapper::canHandleType()   A

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
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * Map general Models.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Autoloader\Mapper;
9
10
use HDNET\Autoloader\MapperInterface;
11
use HDNET\Autoloader\Utility\ReflectionUtility;
12
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
13
14
/**
15
 * Map general Models.
16
 */
17
class ModelMapper implements MapperInterface
18
{
19
    /**
20
     * Check if the current mapper can handle the given type.
21
     *
22
     * @param string $type
23
     *
24
     * @return bool
25
     */
26
    public function canHandleType($type)
27
    {
28
        return ReflectionUtility::isClassInOtherClassHierarchy($type, AbstractEntity::class);
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
        $baseConfig = [
42
            'type' => 'user',
43
            'userFunc' => 'HDNET\\Autoloader\\UserFunctions\\Tca->modelInfoField',
44
        ];
45
46
        return [
47
            'exclude' => 1,
48
            'label' => $overWriteLabel ? $overWriteLabel : $fieldName,
49
            'config' => $baseConfig,
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