Completed
Push — master ( b5054b...5e1fc6 )
by Julián
02:29
created

OptionsTrait::setOptions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
/*
4
 * doctrine-manager-builder (https://github.com/juliangut/doctrine-manager-builder).
5
 * Doctrine2 managers builder.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/doctrine-manager-builder
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
namespace Jgut\Doctrine\ManagerBuilder\Util;
13
14
/**
15
 * Options trait.
16
 */
17
trait OptionsTrait
18
{
19
    /**
20
     * Builder options.
21
     *
22
     * @var array
23
     */
24
    protected $options = [];
25
26
    /**
27
     * Retrieve builder options.
28
     *
29
     * @return array
30
     */
31
    public function getOptions()
32
    {
33
        return $this->options;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getOption($option, $default = null)
40
    {
41
        return array_key_exists($option, $this->options) ? $this->options[$option] : $default;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function hasOption($option)
48
    {
49
        return array_key_exists($option, $this->options);
50
    }
51
52
    /**
53
     * Set builder options.
54
     *
55
     * @param array $options
56
     *
57
     * @return $this
58
     */
59
    public function setOptions(array $options)
60
    {
61
        foreach ($options as $option => $value) {
62
            $this->setOption($option, $value);
63
        }
64
65
        return $this;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     *
71
     * @return $this
72
     */
73
    public function setOption($option, $value)
74
    {
75
        $this->options[$option] = $value;
76
77
        return $this;
78
    }
79
}
80