Completed
Pull Request — master (#348)
by
unknown
10:14
created

ParametersTrait   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 86
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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
declare(strict_types=1);
13
14
namespace ONGR\ElasticsearchDSL;
15
16
trait ParametersTrait
17
{
18
    private array $parameters = [];
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
19
20
    public function hasParameter(string $name): bool
21
    {
22
        return isset($this->parameters[$name]);
23
    }
24
25
    public function removeParameter(string $name): void
26
    {
27
        if ($this->hasParameter($name)) {
28
            unset($this->parameters[$name]);
29
        }
30
    }
31
32
    public function getParameter(string $name): mixed
33
    {
34
        return $this->parameters[$name];
35
    }
36
37
    public function getParameters(): array
38
    {
39
        return $this->parameters;
40
    }
41
42
    public function addParameter(string $name, mixed $value): void
43
    {
44
        $this->parameters[$name] = $value;
45
    }
46
47
    public function setParameters(array $parameters): static
48
    {
49
        $this->parameters = $parameters;
50
51
        return $this;
52
    }
53
54
    protected function processArray(array $array = []): array
55
    {
56
        return array_merge($array, $this->parameters);
57
    }
58
}
59