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

View   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 135
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 17
dl 0
loc 135
c 0
b 0
f 0
rs 10

15 Methods

Rating   Name   Duplication   Size   Complexity  
A setType() 0 4 1
A getParameter() 0 3 1
A getIgnoredProperties() 0 3 1
A setParameters() 0 4 1
A setParameter() 0 4 1
A forgetIgnoredProperty() 0 4 1
A hasParameter() 0 3 1
A forgetExistingProperty() 0 4 1
A addIgnoredProperty() 0 4 1
A getExistingProperties() 0 3 1
A addExistingProperty() 0 4 1
A getParameters() 0 3 1
A getType() 0 3 1
A setExistingProperties() 0 7 2
A setIgnoredProperties() 0 7 2
1
<?php
2
3
namespace AmaTeam\ElasticSearch\API\Entity\Mapping\Structure;
4
5
class View implements ViewInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    private $type;
11
    /**
12
     * @var array
13
     */
14
    private $parameters = [];
15
    /**
16
     * @var string[]
17
     */
18
    private $ignoredProperties = [];
19
    /**
20
     * @var string[]
21
     */
22
    private $existingProperties = [];
23
24
    /**
25
     * @return string
26
     */
27
    public function getType(): ?string
28
    {
29
        return $this->type;
30
    }
31
32
    /**
33
     * @param string $type
34
     * @return $this
35
     */
36
    public function setType(string $type): View
37
    {
38
        $this->type = $type;
39
        return $this;
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function getParameters(): array
46
    {
47
        return $this->parameters;
48
    }
49
50
    /**
51
     * @param array $parameters
52
     * @return $this
53
     */
54
    public function setParameters(array $parameters): View
55
    {
56
        $this->parameters = $parameters;
57
        return $this;
58
    }
59
60
    public function hasParameter(string $parameter): bool
61
    {
62
        return isset($this->parameters[$parameter]);
63
    }
64
65
    public function getParameter(string $parameter)
66
    {
67
        return $this->parameters[$parameter] ?? null;
68
    }
69
70
    public function setParameter(string $parameter, $value): View
71
    {
72
        $this->parameters[$parameter] = $value;
73
        return $this;
74
    }
75
76
    /**
77
     * @return string[]
78
     */
79
    public function getIgnoredProperties(): array
80
    {
81
        return array_values($this->ignoredProperties);
82
    }
83
84
    public function setIgnoredProperties(array $properties): View
85
    {
86
        $this->ignoredProperties = [];
87
        foreach ($properties as $property) {
88
            $this->addIgnoredProperty($property);
89
        }
90
        return $this;
91
    }
92
93
    /**
94
     * @param string $property
95
     * @return View
96
     */
97
    public function addIgnoredProperty(string $property): View
98
    {
99
        $this->ignoredProperties[$property] = $property;
100
        return $this;
101
    }
102
103
    public function forgetIgnoredProperty(string $name): View
104
    {
105
        unset($this->ignoredProperties[$name]);
106
        return $this;
107
    }
108
109
    /**
110
     * @return string[]
111
     */
112
    public function getExistingProperties(): array
113
    {
114
        return array_values($this->existingProperties);
115
    }
116
117
    /**
118
     * @param string[] $existingProperties
119
     * @return $this
120
     */
121
    public function setExistingProperties(array $existingProperties): View
122
    {
123
        $this->existingProperties = [];
124
        foreach ($existingProperties as $property) {
125
            $this->addExistingProperty($property);
126
        }
127
        return $this;
128
    }
129
130
    public function addExistingProperty(string $property): View
131
    {
132
        $this->existingProperties[$property] = $property;
133
        return $this;
134
    }
135
136
    public function forgetExistingProperty(string $property): View
137
    {
138
        unset($this->existingProperties[$property]);
139
        return $this;
140
    }
141
}
142