FieldDefinition   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B configureOptions() 0 33 1
A getClassMetadataMethod() 0 4 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Component\DoctrineEnhancer\Definition;
14
15
use Symfony\Component\OptionsResolver\OptionsResolver;
16
17
/**
18
 * Class FieldDefinition
19
 *
20
 * @author  Adam Piotrowski <[email protected]>
21
 */
22
final class FieldDefinition extends AbstractMappingDefinition
23
{
24
    public function configureOptions(OptionsResolver $resolver)
25
    {
26
        $resolver->setRequired([
27
            'fieldName',
28
            'type',
29
            'length',
30
            'unique',
31
            'nullable',
32
            'columnName',
33
            'options',
34
            'precision',
35
            'scale',
36
        ]);
37
        
38
        $resolver->setDefaults([
39
            'length'    => 50,
40
            'unique'    => false,
41
            'nullable'  => true,
42
            'options'   => [],
43
            'precision' => 15,
44
            'scale'     => 2,
45
        ]);
46
        
47
        $resolver->setAllowedTypes('fieldName', 'string');
48
        $resolver->setAllowedTypes('type', 'string');
49
        $resolver->setAllowedTypes('length', 'integer');
50
        $resolver->setAllowedTypes('unique', 'boolean');
51
        $resolver->setAllowedTypes('nullable', 'boolean');
52
        $resolver->setAllowedTypes('columnName', 'string');
53
        $resolver->setAllowedTypes('precision', 'numeric');
54
        $resolver->setAllowedTypes('scale', 'numeric');
55
        $resolver->setAllowedTypes('options', 'array');
56
    }
57
    
58
    public function getClassMetadataMethod(): string
59
    {
60
        return MappingDefinitionInterface::CLASS_METADATA_METHOD_FIELD;
61
    }
62
}
63