AchievementProviderPluginManager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validatePlugin() 0 14 3
1
<?php
2
/**
3
 * AchievementProviderPluginManager
4
 *
5
 * @category  AxalianAchievements\AchievementProvider
6
 * @package   AxalianAchievements\AchievementProvider
7
 * @author    Michel Maas <[email protected]>
8
 */
9
10
namespace AxalianAchievements\AchievementProvider;
11
12
use AxalianAchievements\Exception\RuntimeException;
13
use Zend\ServiceManager\AbstractPluginManager;
14
15
class AchievementProviderPluginManager extends AbstractPluginManager
16
{
17
    /**
18
     * Validate the plugin
19
     *
20
     * Checks that the filter loaded is either a valid callback or an instance
21
     * of FilterInterface.
22
     *
23
     * @param  mixed $plugin
24
     * @throws RuntimeException
25
     * @return void
26
     */
27
    public function validatePlugin($plugin)
28
    {
29
        if ($plugin instanceof AchievementProviderInterface) {
30
            return; // we're okay
31
        }
32
33
        throw new RuntimeException(
34
            sprintf(
35
                'Plugin of type %s is invalid; must implement ' .
36
                'AxalianAchievements\AchievementProvider\AchievementProviderInterface',
37
                (is_object($plugin) ? get_class($plugin) : gettype($plugin))
38
            )
39
        );
40
    }
41
}
42