Completed
Pull Request — master (#1069)
by
unknown
07:37
created

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