Completed
Push — master ( f2f7ef...c782fc )
by Karel
04:31 queued 10s
created

IndexPopulateEvent::setReset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://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
class IndexPopulateEvent extends IndexEvent
20
{
21
    /**
22
     * @Event("FOS\ElasticaBundle\Event\IndexPopulateEvent")
23
     */
24
    const PRE_INDEX_POPULATE = 'elastica.index.index_pre_populate';
25
26
    /**
27
     * @Event("FOS\ElasticaBundle\Event\IndexPopulateEvent")
28
     */
29
    const POST_INDEX_POPULATE = 'elastica.index.index_post_populate';
30
31
    /**
32
     * @var bool
33
     */
34
    private $reset;
35
36
    /**
37
     * @var array
38
     */
39
    private $options;
40
41
    /**
42
     * @param string $index
43
     * @param bool   $reset
44
     * @param array  $options
45
     */
46 5
    public function __construct($index, $reset, $options)
47
    {
48 5
        parent::__construct($index);
49
50 5
        $this->reset = $reset;
51 5
        $this->options = $options;
52 5
    }
53
54
    /**
55
     * @return bool
56
     */
57 3
    public function isReset()
58
    {
59 3
        return $this->reset;
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function getOptions()
66
    {
67
        return $this->options;
68
    }
69
70
    /**
71
     * @param bool $reset
72
     */
73 1
    public function setReset($reset)
74
    {
75 1
        $this->reset = $reset;
76 1
    }
77
78
    /**
79
     * @param string $name
80
     *
81
     * @return mixed
82
     *
83
     * @throws \InvalidArgumentException if option does not exist
84
     */
85 2
    public function getOption($name)
86
    {
87 2
        if (!isset($this->options[$name])) {
88 1
            throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
89
        }
90
91 1
        return $this->options[$name];
92
    }
93
94
    /**
95
     * @param string $name
96
     * @param mixed  $value
97
     */
98
    public function setOption($name, $value)
99
    {
100
        $this->options[$name] = $value;
101
    }
102
}
103