Completed
Push — master ( dd1c3d...bd2aeb )
by Mateusz
40s
created

SenderPluginManager::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * MtMail - e-mail module for Zend Framework 2
4
 *
5
 * @link      http://github.com/mtymek/MtMail
6
 * @copyright Copyright (c) 2013-2014 Mateusz Tymek
7
 * @license   BSD 2-Clause
8
 */
9
10
namespace MtMail\Service;
11
12
use MtMail\Exception\RuntimeException;
13
use MtMail\SenderPlugin\PluginInterface;
14
use Zend\ServiceManager\AbstractPluginManager;
15
use Zend\ServiceManager\Exception;
16
use Zend\ServiceManager\ServiceLocatorAwareInterface;
17
use Zend\ServiceManager\ServiceLocatorInterface;
18
use Zend\ServiceManager\ServiceManager;
19
20
class SenderPluginManager extends AbstractPluginManager
21
{
22
23
    /**
24
     * The main service locator
25
     *
26
     * @var ServiceLocatorInterface
27
     */
28
    protected $serviceLocator;
29
30
    /**
31
     * Validate the plugin
32
     *
33
     *
34
     * @param  mixed            $plugin
35
     * @throws RuntimeException
36
     * @return void
37
     */
38 4
    public function validatePlugin($plugin)
39
    {
40 4
        if (!$plugin instanceof PluginInterface) {
41 2
            throw new RuntimeException(sprintf(
42 2
                'Plugin of type %s is invalid; must implement %s\FilterInterface or be callable',
43 2
                (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
44
                __NAMESPACE__
45 2
            ));
46
        }
47 2
    }
48
49
    /**
50
     * sm v3
51
     * @param  mixed   $plugin
52
     * @return void
53
     */
54 2
    public function validate($plugin)
55
    {
56 2
        $this->validatePlugin($plugin);
57 1
    }
58
59
    /**
60
     * Canonicalize name
61
     *
62
     * @param  string $name
63
     * @return string
64
     */
65
    protected function canonicalizeName($name)
66
    {
67
        return $name;
68
    }
69
}
70