Completed
Pull Request — master (#1069)
by
unknown
11:44
created

TypeConfig::getNumericDetection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

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