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

TemplateManager::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\Template\TemplateInterface;
14
use Zend\ServiceManager\AbstractPluginManager;
15
use Zend\ServiceManager\Exception;
16
17
class TemplateManager extends AbstractPluginManager
18
{
19
20
    /**
21
     * Validate the plugin
22
     *
23
     * Checks that the filter loaded is either a valid callback or an instance
24
     * of FilterInterface.
25
     *
26
     * @param  mixed            $plugin
27
     * @throws RuntimeException
28
     * @return void
29
     */
30 4
    public function validatePlugin($plugin)
31
    {
32 4
        if (!$plugin instanceof TemplateInterface) {
33 2
            $class = get_class($plugin);
34 2
            throw new RuntimeException("E-mail template must implement TemplateInterface, '$class' was given.");
35
        }
36 2
    }
37
38
    /**
39
     * sm v3
40
     * @param  mixed   $plugin
41
     * @return void
42
     */
43 2
    public function validate($plugin)
44
    {
45 2
        $this->validatePlugin($plugin);
46 1
    }
47
}
48