Completed
Pull Request — dev (#9)
by Arnaud
02:46
created

Field::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 2 Features 1
Metric Value
c 2
b 2
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace LAG\AdminBundle\Field;
4
5
use LAG\AdminBundle\Application\Configuration\ApplicationConfiguration;
6
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
7
use Symfony\Component\Translation\TranslatorInterface;
8
use Twig_Environment;
9
10
abstract class Field implements FieldInterface, TranslatableFieldInterface, TwigFieldInterface
11
{
12
    const TYPE_STRING = 'string';
13
    const TYPE_LINK = 'link';
14
    const TYPE_ARRAY = 'array';
15
    const TYPE_DATE = 'date';
16
    const TYPE_COUNT = 'count';
17
    const TYPE_ACTION = 'action';
18
    const TYPE_COLLECTION = 'collection';
19
    const TYPE_BOOLEAN = 'boolean';
20
21
    /**
22
     * Field's name
23
     *
24
     * @var string
25
     */
26
    protected $name;
27
28
    /**
29
     * Application configuration for default options
30
     *
31
     * @var ApplicationConfiguration
32
     */
33
    protected $applicationConfiguration;
34
35
    /**
36
     * Field's resolved options
37
     *
38
     * @var ParameterBag
39
     */
40
    protected $options;
41
42
    /**
43
     * Twig engine
44
     *
45
     * @var Twig_Environment
46
     */
47
    protected $twig;
48
49
    /**
50
     * Translator
51
     *
52
     * @var TranslatorInterface
53
     */
54
    protected $translator;
55
56
    /**
57
     * Field constructor.
58
     */
59 5
    public function __construct()
60
    {
61 5
        $this->options = new ParameterBag();
62 5
    }
63
64
    /**
65
     * @return string
66
     */
67 1
    public function getName()
68
    {
69 1
        return $this->name;
70
    }
71
72
    /**
73
     * @param string $name
74
     */
75 1
    public function setName($name)
76
    {
77 1
        $this->name = $name;
78 1
    }
79
80
    /**
81
     * Return application configuration.
82
     *
83
     * @return ApplicationConfiguration
84
     */
85
    public function getApplicationConfiguration()
86
    {
87
        return $this->applicationConfiguration;
88
    }
89
90
    /**
91
     * @param ApplicationConfiguration $configuration
92
     */
93 3
    public function setApplicationConfiguration($configuration)
94
    {
95 3
        $this->applicationConfiguration = $configuration;
96 3
    }
97
98
    /**
99
     * @param TranslatorInterface $translator
100
     */
101 3
    public function setTranslator(TranslatorInterface $translator)
102
    {
103 3
        $this->translator = $translator;
104 3
    }
105
106
    /**
107
     * Set resolved options.
108
     *
109
     * @param array $options
110
     * @return void
111
     */
112 2
    public function setOptions(array $options)
113
    {
114 2
        $this->options = new ParameterBag($options);
115 2
    }
116
117
    /**
118
     * Set twig environment.
119
     *
120
     * @param Twig_Environment $twig
121
     */
122 3
    public function setTwig(Twig_Environment $twig)
123
    {
124 3
        $this->twig = $twig;
125 3
    }
126
}
127