Passed
Push — feature/initial-implementation ( 4684a2...a02498 )
by Fike
01:36
created

DefaultContext::setRemoveUnknownParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\API\Mapping\Normalization;
6
7
class DefaultContext implements ContextInterface
8
{
9
    /**
10
     * @var bool
11
     */
12
    private $removeUnknownParams = true;
13
    /**
14
     * @var string[]
15
     */
16
    private $ignoredParameters = [];
17
    /**
18
     * @var string[]
19
     */
20
    private $path = [];
21
    /**
22
     * @var string
23
     */
24
    private $className;
25
26
    public static function from(ContextInterface $context): DefaultContext
27
    {
28
        return (new DefaultContext())
29
            ->setRemoveUnknownParams($context->shouldRemoveUnknownParams())
30
            ->setIgnoredParameters($context->getIgnoredParameters())
31
            ->setPath($context->getPath());
32
    }
33
34
    /**
35
     * @return bool
36
     */
37
    public function shouldRemoveUnknownParams(): bool
38
    {
39
        return $this->removeUnknownParams;
40
    }
41
42
    /**
43
     * @param bool $removeUnknownParams
44
     * @return $this
45
     */
46
    public function setRemoveUnknownParams(bool $removeUnknownParams)
47
    {
48
        $this->removeUnknownParams = $removeUnknownParams;
49
        return $this;
50
    }
51
52
    /**
53
     * @return string[]
54
     */
55
    public function getIgnoredParameters(): array
56
    {
57
        return $this->ignoredParameters;
58
    }
59
60
    /**
61
     * @param string[] $ignoredParameters
62
     * @return $this
63
     */
64
    public function setIgnoredParameters(array $ignoredParameters)
65
    {
66
        $this->ignoredParameters = $ignoredParameters;
67
        return $this;
68
    }
69
70
    /**
71
     * @return string[]
72
     */
73
    public function getPath(): array
74
    {
75
        return $this->path;
76
    }
77
78
    /**
79
     * @param string[] $path
80
     * @return $this
81
     */
82
    public function setPath(array $path)
83
    {
84
        $this->path = $path;
85
        return $this;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getClassName(): string
92
    {
93
        return $this->className;
94
    }
95
96
    /**
97
     * @param string $className
98
     * @return $this
99
     */
100
    public function setClassName(string $className)
101
    {
102
        $this->className = $className;
103
        return $this;
104
    }
105
}
106