ImagineFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 18
ccs 4
cts 6
cp 0.6667
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Service;
6
7
use Exception;
8
use Gmagick;
9
use Imagick;
10
use Imagine\Image\ImagineInterface;
11
use Imagine\Imagick\Imagine;
12
use Laminas\ServiceManager\Factory\FactoryInterface;
13
use Psr\Container\ContainerInterface;
14
15
final class ImagineFactory implements FactoryInterface
16
{
17
    /**
18
     * Return the preferred driver available on this system.
19
     *
20
     * @param string $requestedName
21
     */
22 9
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): ImagineInterface
23
    {
24 9
        if (class_exists(Gmagick::class)) {
25
            return new \Imagine\Gmagick\Imagine();
26
        }
27
28 9
        if (class_exists(Imagick::class)) {
29 9
            return new Imagine();
30
        }
31
32
        throw new Exception('Gmagick and Imagick are missing, install one of those module');
33
    }
34
}
35