Completed
Push — master ( 4ce1e5...05c57d )
by Tim
13:09 queued 03:24
created

TypeConfig::getDynamic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
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 5
    public function __construct($name, array $mapping, array $config = array())
32
    {
33 5
        $this->config = $config;
34 5
        $this->mapping = $mapping;
35 5
        $this->name = $name;
36 5
    }
37
38
    /**
39
     * @return bool|null
40
     */
41 3
    public function getDateDetection()
42
    {
43 3
        return $this->getConfig('date_detection');
44
    }
45
46
    /**
47
     * @return array
48
     */
49 3
    public function getDynamicDateFormats()
50
    {
51 3
        return $this->getConfig('dynamic_date_formats');
52
    }
53
54
    /**
55
     * @return string|null
56
     */
57 3
    public function getIndexAnalyzer()
58
    {
59 3
        return $this->getConfig('index_analyzer');
60
    }
61
62
    /**
63
     * @return array
64
     */
65 3
    public function getMapping()
66
    {
67 3
        return $this->mapping;
68
    }
69
70
    /**
71
     * @return string|null
72
     */
73 3
    public function getModel()
74
    {
75 3
        return isset($this->config['persistence']['model']) ?
76 1
            $this->config['persistence']['model'] :
77 3
            null;
78
    }
79
80
    /**
81
     * @return bool|null
82
     */
83 3
    public function getNumericDetection()
84
    {
85 3
        return $this->getConfig('numeric_detection');
86
    }
87
88
    /**
89
     * @return string
90
     */
91 2
    public function getName()
92
    {
93 2
        return $this->name;
94
    }
95
96
    /**
97
     * @return string|null
98
     */
99 3
    public function getSearchAnalyzer()
100
    {
101 3
        return $this->getConfig('search_analyzer');
102
    }
103
104
    /**
105
     * @return string|null
106
     */
107 3
    public function getDynamic()
108
    {
109 3
        return $this->getConfig('dynamic');
110 3
    }
111 3
112
    /**
113
     * @param string $key
114
     * @return null|string
115
     */
116
    private function getConfig($key)
117
    {
118
        return isset($this->config[$key]) ?
119
            $this->config[$key] :
120
            null;
121
    }
122
}
123