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

AbstractIndexPopulateEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 44
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A isReset() 0 4 1
A getOptions() 0 4 1
A getOption() 0 8 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 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