Completed
Push — extensions-support ( 5c6110...f3b32a )
by Patrick
03:47
created

ExtensibleClassMetadata::appendExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Extensions;
4
5
use Doctrine\ORM\Mapping\ClassMetadata;
6
7
class ExtensibleClassMetadata extends ClassMetadata
8
{
9
    /**
10
     * A dictionary of extension metadata mapped to this class.
11
     *
12
     * @var array
13
     */
14
    public $extensions = [];
15
16
    /**
17
     * @param string $name
18
     * @param array  $configuration
19
     *
20
     * @return void
21
     */
22 28
    public function addExtension($name, array $configuration)
23
    {
24 28
        $this->extensions[$name] = $configuration;
25 28
    }
26
27
    /**
28
     * @param string $name
29
     *
30
     * @return array
31
     */
32 28
    public function getExtension($name)
33
    {
34 28
        if (isset($this->extensions[$name])) {
35 28
            return $this->extensions[$name];
36
        }
37
38 7
        return [];
39
    }
40
41
    /**
42
     * @param string $name
43
     * @param array  $config
44
     */
45 4
    public function appendExtension($name, array $config = [])
46
    {
47 4
        $merged = array_merge(
48 4
            $this->getExtension($name),
49
            $config
50 4
        );
51
52 4
        $this->addExtension($name, $merged);
53 4
    }
54
}
55