Completed
Pull Request — master (#1741)
by
unknown
03:22 queued 40s
created

IndexPopulateEvent::setReset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <https://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
namespace FOS\ElasticaBundle\Event;
13
14
/**
15
 * Index Populate Event.
16
 *
17
 * @author Oleg Andreyev <[email protected]>
18
 */
19
abstract class IndexPopulateEvent extends IndexEvent
20
{
21
    /**
22
     * @var bool
23
     */
24
    private $reset;
25
26
    /**
27
     * @var array
28
     */
29
    private $options;
30
31 2
    public function __construct(string $index, bool $reset, array $options)
32
    {
33 2
        parent::__construct($index);
34
35 2
        $this->reset = $reset;
36 2
        $this->options = $options;
37 2
    }
38
39 2
    public function isReset(): bool
40
    {
41 2
        return $this->reset;
42
    }
43
44
    public function getOptions(): array
45
    {
46
        return $this->options;
47
    }
48
49
    public function setReset(bool $reset)
50
    {
51
        $this->reset = $reset;
52
    }
53
54
    /**
55
     * @return mixed
56
     *
57
     * @throws \InvalidArgumentException if option does not exist
58
     */
59 1
    public function getOption(string $name)
60
    {
61 1
        if (!isset($this->options[$name])) {
62
            throw new \InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name));
63
        }
64
65 1
        return $this->options[$name];
66
    }
67
68
    /**
69
     * @param string $name
70
     * @param mixed  $value
71
     */
72
    public function setOption($name, $value)
73
    {
74
        $this->options[$name] = $value;
75
    }
76
}
77