Completed
Push — master ( d34e64...7e6b75 )
by Julián
06:06
created

OptionsTrait::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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;
13
14
use Doctrine\Common\Annotations\AnnotationRegistry;
15
use Doctrine\Common\Cache\ApcuCache;
16
use Doctrine\Common\Cache\ArrayCache;
17
use Doctrine\Common\Cache\CacheProvider;
18
use Doctrine\Common\Cache\MemcacheCache;
19
use Doctrine\Common\Cache\RedisCache;
20
use Doctrine\Common\Cache\XcacheCache;
21
use Doctrine\Common\EventManager;
22
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
23
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
24
use Doctrine\Common\Persistence\Mapping\Driver\PHPDriver;
25
use Doctrine\Common\Proxy\AbstractProxyFactory;
26
27
/**
28
 * Options trait.
29
 */
30
trait OptionsTrait
31
{
32
    /**
33
     * Builder options.
34
     *
35
     * @var array
36
     */
37
    protected $options = [];
38
39
    /**
40
     * Retrieve builder options.
41
     *
42
     * @return array
43
     */
44
    public function getOptions()
45
    {
46
        return $this->options;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getOption($option, $default = null)
53
    {
54
        return array_key_exists($option, $this->options) ? $this->options[$option] : $default;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function hasOption($option)
61
    {
62
        return array_key_exists($option, $this->options);
63
    }
64
65
    /**
66
     * Set builder options.
67
     *
68
     * @param array $options
69
     *
70
     * @return $this
71
     */
72
    public function setOptions(array $options)
73
    {
74
        foreach ($options as $option => $value) {
75
            $this->setOption($option, $value);
76
        }
77
78
        return $this;
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     *
84
     * @return $this
85
     */
86
    public function setOption($option, $value)
87
    {
88
        $this->options[$option] = $value;
89
90
        return $this;
91
    }
92
}
93