ErrorResponseGeneratorManager::validate()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 3
rs 9.8666
c 0
b 0
f 0
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