PluginManager   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 69
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A hasPlugins() 0 4 1
A getPlugins() 0 4 1
A hasPlugin() 0 4 1
A getPlugin() 0 8 2
A __construct() 0 4 1
A setPlugins() 0 6 2
A setPlugin() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory CKEditor package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\CKEditorBundle\Model;
13
14
use Ivory\CKEditorBundle\Exception\PluginManagerException;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class PluginManager implements PluginManagerInterface
20
{
21
    /**
22
     * @var array
23
     */
24
    private $plugins = [];
25
26
    /**
27
     * @param array $plugins
28
     */
29 170
    public function __construct(array $plugins = [])
30
    {
31 170
        $this->setPlugins($plugins);
32 170
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 30
    public function hasPlugins()
38
    {
39 30
        return !empty($this->plugins);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 30
    public function getPlugins()
46
    {
47 30
        return $this->plugins;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 170
    public function setPlugins(array $plugins)
54
    {
55 170
        foreach ($plugins as $name => $plugin) {
56 30
            $this->setPlugin($name, $plugin);
57 136
        }
58 170
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 30
    public function hasPlugin($name)
64
    {
65 30
        return isset($this->plugins[$name]);
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 20
    public function getPlugin($name)
72
    {
73 20
        if (!$this->hasPlugin($name)) {
74 10
            throw PluginManagerException::pluginDoesNotExist($name);
75
        }
76
77 10
        return $this->plugins[$name];
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83 30
    public function setPlugin($name, array $plugin)
84
    {
85 30
        $this->plugins[$name] = $plugin;
86 30
    }
87
}
88