Passed
Push — feature/initial-implementation ( fae671...591f29 )
by Fike
02:37
created

Mapping   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 14
dl 0
loc 113
c 0
b 0
f 0
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A removeProperty() 0 4 1
A getProperty() 0 3 1
A setProperty() 0 4 1
A setParameter() 0 4 1
A hasParameter() 0 3 1
A getParameter() 0 3 1
A setProperties() 0 4 1
A setParameters() 0 4 1
A getParameters() 0 3 1
A __construct() 0 3 1
A getType() 0 3 1
A setType() 0 4 1
A getProperties() 0 3 1
A hasProperty() 0 3 1
1
<?php
2
3
namespace AmaTeam\ElasticSearch\API;
4
5
class Mapping implements MappingInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    private $type;
11
    /**
12
     * @var array
13
     */
14
    private $parameters = [];
15
    /**
16
     * @var MappingInterface[]
17
     */
18
    private $properties = [];
19
20
    /**
21
     * @param string $type
22
     */
23
    public function __construct(string $type = null)
24
    {
25
        $this->type = $type;
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function getType(): ?string
32
    {
33
        return $this->type;
34
    }
35
36
    /**
37
     * @param string $type
38
     * @return $this
39
     */
40
    public function setType(string $type): Mapping
41
    {
42
        $this->type = $type;
43
        return $this;
44
    }
45
46
    public function hasParameter(string $name): bool
47
    {
48
        return array_key_exists($name, $this->parameters);
49
    }
50
51
    public function getParameter(string $name)
52
    {
53
        return $this->parameters[$name] ?? null;
54
    }
55
56
    public function setParameter(string $parameter, $value): Mapping
57
    {
58
        $this->parameters[$parameter] = $value;
59
        return $this;
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function getParameters(): array
66
    {
67
        return $this->parameters;
68
    }
69
70
    /**
71
     * @param array $parameters
72
     * @return $this
73
     */
74
    public function setParameters(array $parameters): Mapping
75
    {
76
        $this->parameters = $parameters;
77
        return $this;
78
    }
79
80
    public function hasProperty(string $name): bool
81
    {
82
        return isset($this->properties[$name]);
83
    }
84
85
    public function getProperty(string $name): ?MappingInterface
86
    {
87
        return $this->properties[$name] ?? null;
88
    }
89
90
    public function setProperty(string $name, MappingInterface $mapping): Mapping
91
    {
92
        $this->properties[$name] = $mapping;
93
        return $this;
94
    }
95
96
    public function removeProperty(string $name): Mapping
97
    {
98
        unset($this->properties[$name]);
99
        return $this;
100
    }
101
102
    /**
103
     * @return MappingInterface[]
104
     */
105
    public function getProperties(): array
106
    {
107
        return $this->properties;
108
    }
109
110
    /**
111
     * @param MappingInterface[] $properties
112
     * @return $this
113
     */
114
    public function setProperties(array $properties): Mapping
115
    {
116
        $this->properties = $properties;
117
        return $this;
118
    }
119
}
120