YumlControllerFactory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 0
loc 39
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createService() 0 8 3
A __invoke() 0 19 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineORMModule\Yuml;
6
7
use Interop\Container\ContainerInterface;
8
use Laminas\Http\Client;
9
use Laminas\ServiceManager\AbstractPluginManager;
10
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
11
use Laminas\ServiceManager\FactoryInterface;
12
use Laminas\ServiceManager\ServiceLocatorInterface;
13
use function sprintf;
14
15
class YumlControllerFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Laminas\ServiceManager\FactoryInterface has been deprecated with message: Use Laminas\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
16
{
17
    /**
18
     * Create service
19
     */
20 3
    public function createService(ServiceLocatorInterface $serviceLocator) : YumlController
21
    {
22 3
        if ($serviceLocator instanceof AbstractPluginManager) {
23 3
            $serviceLocator = $serviceLocator->getServiceLocator() ?: $serviceLocator;
0 ignored issues
show
Deprecated Code introduced by
The method Laminas\ServiceManager\S...er::getServiceLocator() has been deprecated with message: since 3.0.0. Factories using 3.0 should use the container instance passed to the factory instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
24
        }
25
26 3
        return $this($serviceLocator, YumlController::class);
27
    }
28
29
    /**
30
     * Create an object
31
     *
32
     * {@inheritDoc}
33
     */
34 3
    public function __invoke(
35
        ContainerInterface $container,
36
        $requestedName,
37
        ?array $options = null
38
    ) : YumlController {
39 3
        $config = $container->get('config');
40
41 3
        if (! isset($config['laminas-developer-tools']['toolbar']['enabled'])
42 3
            || ! $config['laminas-developer-tools']['toolbar']['enabled']
43
        ) {
44 2
            throw new ServiceNotFoundException(
45 2
                sprintf('Service %s could not be found', YumlController::class)
46
            );
47
        }
48
49 1
        return new YumlController(
50 1
            new Client('https://yuml.me/diagram/plain/class/', ['timeout' => 30])
51
        );
52
    }
53
}
54