TextView::getTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 1
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Field\View;
6
7
use LAG\AdminBundle\Exception\Exception;
8
use LAG\AdminBundle\Exception\Field\ViewException;
9
10
class TextView implements View
11
{
12
    private string $name;
13
    private array $options;
14
    private ?\Closure $dataTransformer;
15
16
    public function __construct(string $name, array $options = [], ?\Closure $dataTransformer = null)
17 1
    {
18
        $this->name = $name;
19 1
        $this->options = $options;
20 1
        $this->dataTransformer = $dataTransformer;
21 1
    }
22 1
23
    public function getName(): string
24
    {
25
        return $this->name;
26
    }
27
28
    public function getOptions(): array
29
    {
30
        return $this->options;
31
    }
32
33
    public function getOption(string $name)
34
    {
35
        if (!\array_key_exists($name, $this->options)) {
36
            throw new Exception('Invalid option "'.$name.'" for field "'.$this->getName().'"');
37
        }
38
39
        return $this->options[$name];
40
    }
41
42
    public function getTemplate(): string
43
    {
44
        throw new ViewException('The getTemplate() method does not exists for TextView');
45
    }
46
47
    public function getDataTransformer(): ?\Closure
48
    {
49
        return $this->dataTransformer;
50
    }
51
}
52