ErrorResponseGeneratorManager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Acelaya\ExpressiveErrorHandler\ErrorHandler;
6
7
use Zend\ServiceManager\AbstractPluginManager;
8
use Zend\ServiceManager\Exception\InvalidServiceException;
9
10
use function get_class;
11
use function gettype;
12
use function is_callable;
13
use function is_object;
14
use function sprintf;
15
16
class ErrorResponseGeneratorManager extends AbstractPluginManager implements ErrorResponseGeneratorManagerInterface
17
{
18
    /**
19
     * @param mixed $instance
20
     * @throws InvalidServiceException
21
     */
22 6
    public function validate($instance)
23
    {
24 6
        if (is_callable($instance)) {
25 6
            return;
26
        }
27
28 1
        throw new InvalidServiceException(sprintf(
29 1
            'Only callables are valid plugins for "%s", but "%s" was provided',
30 1
            __CLASS__,
31 1
            is_object($instance) ? get_class($instance) : gettype($instance)
32
        ));
33
    }
34
}
35