Completed
Push — master ( fbc1fa...9bba21 )
by
unknown
14s
created

TypeConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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