Completed
Push — master ( f4b0de...7c84cc )
by
unknown
17s queued 10s
created

AbstractIndexPopulateEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
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 AbstractIndexPopulateEvent extends AbstractIndexEvent
20
{
21
    /**
22
     * @var bool
23
     */
24
    protected $reset;
25
26
    /**
27
     * @var array
28
     */
29
    protected $options;
30
31 10
    public function __construct(string $index, bool $reset, array $options)
32
    {
33 10
        parent::__construct($index);
34
35 10
        $this->reset = $reset;
36 10
        $this->options = $options;
37 10
    }
38
39 6
    public function isReset(): bool
40
    {
41 6
        return $this->reset;
42
    }
43
44 4
    public function getOptions(): array
45
    {
46 4
        return $this->options;
47
    }
48
49
    /**
50
     * @return mixed
51
     *
52
     * @throws \InvalidArgumentException if option does not exist
53
     */
54 5
    public function getOption(string $name)
55
    {
56 5
        if (!isset($this->options[$name])) {
57 2
            throw new \InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name));
58
        }
59
60 3
        return $this->options[$name];
61
    }
62
}
63