EventOptionsTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 36
rs 10

2 Methods

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