EventOptionsTrait::getOption()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of Sulu
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Component\DocumentManager\Event;
13
14
use Symfony\Component\OptionsResolver\OptionsResolver;
15
16
/**
17
 * This trait adds options to an event.
18
 */
19
trait EventOptionsTrait
20
{
21
    /**
22
     * This array is used as key value storage for the options.
23
     *
24
     * @var OptionsResolver
25
     */
26
    protected $options;
27
28
    /**
29
     * Returns all the options for the event.
30
     *
31
     * @return OptionsResolver
32
     */
33
    public function getOptions()
34
    {
35
        return $this->options;
36
    }
37
38
    /**
39
     * Returns the option with the given name.
40
     *
41
     * @param string $name The name of the option
42
     * @param mixed $default The return value in case the option is not set
43
     *
44
     * @return mixed The value of the option
45
     */
46
    public function getOption($name, $default = null)
47
    {
48
        if (isset($this->options[$name])) {
49
            return $this->options[$name];
50
        }
51
52
        return $default;
53
    }
54
}
55