Completed
Pull Request — master (#1069)
by Giovanni
11:08
created

TypeConfig::getAnalyzer()   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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
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
/**
4
 * This file is part of the FOSElasticaBundle project.
5
 *
6
 * (c) Tim Nagel <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\ElasticaBundle\Configuration;
13
14
class TypeConfig
15
{
16
    /**
17
     * @var array
18
     */
19
    private $config;
20
21
    /**
22
     * @var array
23
     */
24
    private $mapping;
25
26
    /**
27
     * @var string
28
     */
29
    private $name;
30
31
    /**
32
     * @param string $name
33
     * @param array  $mapping
34
     * @param array  $config
35
     */
36 9
    public function __construct($name, array $mapping, array $config = array())
37
    {
38 9
        $this->config = $config;
39 9
        $this->mapping = $mapping;
40 9
        $this->name = $name;
41 9
    }
42
43
    /**
44
     * @return bool|null
45
     */
46 6
    public function getDateDetection()
47
    {
48 6
        return $this->getConfig('date_detection');
49
    }
50
51
    /**
52
     * @return array
53
     */
54 6
    public function getDynamicDateFormats()
55
    {
56 6
        return $this->getConfig('dynamic_date_formats');
57
    }
58
59
    /**
60
     * @return string|null
61
     */
62 6
    public function getAnalyzer()
63
    {
64 6
        return $this->getConfig('analyzer');
65
    }
66
67
    /**
68
     * @return array
69
     */
70 6
    public function getMapping()
71
    {
72 6
        return $this->mapping;
73
    }
74
75
    /**
76
     * @return string|null
77
     */
78 6
    public function getModel()
79
    {
80 6
        return isset($this->config['persistence']['model']) ?
81 6
            $this->config['persistence']['model'] :
82 6
            null;
83
    }
84
85
    /**
86
     * @return bool|null
87
     */
88 6
    public function getNumericDetection()
89
    {
90 6
        return $this->getConfig('numeric_detection');
91
    }
92
93
    /**
94
     * @return string
95
     */
96 3
    public function getName()
97
    {
98 3
        return $this->name;
99
    }
100
101
    /**
102
     * @return string|null
103
     */
104 6
    public function getDynamic()
105
    {
106 6
        return $this->getConfig('dynamic');
107
    }
108
109
    /**
110
     * @param string $key
111
     *
112 6
     * @return null|string
113
     */
114 6
    private function getConfig($key)
115
    {
116
        return isset($this->config[$key]) ?
117
            $this->config[$key] :
118
            null;
119
    }
120
}
121