TransformersManager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 28
ccs 0
cts 11
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validatePlugin() 0 12 3
1
<?php
2
3
namespace SvImages\Transformer;
4
5
use Zend\ServiceManager\AbstractPluginManager;
6
use Zend\ServiceManager\Exception;
7
8
/**
9
 * Class TransformersManager
10
 *
11
 * TransformersManager implementation for managing image transformers
12
 *
13
 * @method \SvImages\Transformer\TransformerInterface get($name)
14
 *
15
 * @author Vytautas Stankus <[email protected]>
16
 * @license MIT
17
 */
18
class TransformersManager extends AbstractPluginManager
19
{
20
    /** {@inheritDoc} */
21
    protected $shareByDefault = false;
22
23
    /**
24
     * Validate the plugin
25
     *
26
     * Checks that the transformer loaded is instance of TransformerInterface.
27
     *
28
     * @param  TransformerInterface $transformer
29
     *
30
     * @return void
31
     * @throws Exception\RuntimeException if invalid
32
     */
33
    public function validatePlugin($transformer)
34
    {
35
        if ($transformer instanceof TransformerInterface) {
36
            return; // we're okay
37
        }
38
39
        throw new Exception\RuntimeException(sprintf(
40
            'Transformer of type %s is invalid; must implement %s',
41
            (is_object($transformer) ? get_class($transformer) : gettype($transformer)),
42
            TransformerInterface::class
43
        ));
44
    }
45
}
46