Completed
Pull Request — master (#1093)
by Oleg
06:31 queued 02:17
created

IndexPopulateEvent   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 84
ccs 0
cts 29
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setReset() 0 4 1
A __construct() 0 7 1
A isReset() 0 4 1
A getOptions() 0 4 1
A getOption() 0 8 2
A setOption() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the FOSElasticaBundle project.
5
 *
6
 * (c) FriendsOfSymfony <https://github.com/FriendsOfSymfony/FOSElasticaBundle/graphs/contributors>
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 boolean $reset
44
     * @param array   $options
45
     */
46
    public function __construct($index, $reset, $options)
47
    {
48
        parent::__construct($index);
49
50
        $this->reset   = $reset;
51
        $this->options = $options;
52
    }
53
54
    /**
55
     * @return boolean
56
     */
57
    public function isReset()
58
    {
59
        return $this->reset;
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function getOptions()
66
    {
67
        return $this->options;
68
    }
69
70
    /**
71
     * @param boolean $reset
72
     */
73
    public function setReset($reset)
74
    {
75
        $this->reset = $reset;
76
    }
77
78
    /**
79
     * @param string $name
80
     *
81
     * @return mixed
82
     *
83
     * @throws \InvalidArgumentException if option does not exist
84
     */
85
    public function getOption($name)
86
    {
87
        if (!isset($this->options[$name])) {
88
            throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
89
        }
90
91
        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