Failed Conditions
Pull Request — master (#11)
by Adrien
15:48 queued 12:33
created

ImagineFactory   A

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 Imagick;
9
use Imagine\Image\ImagineInterface;
10
use Imagine\Imagick\Imagine;
11
use Interop\Container\ContainerInterface;
12
use Laminas\ServiceManager\Factory\FactoryInterface;
13
14
final class ImagineFactory implements FactoryInterface
15
{
16
    /**
17
     * Return the preferred driver available on this system.
18
     *
19
     * @param string $requestedName
20
     */
21 1
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): ImagineInterface
22
    {
23 1
        if (class_exists('Gmagick')) {
24
            return new \Imagine\Gmagick\Imagine();
25
        }
26
27 1
        if (class_exists(Imagick::class)) {
28 1
            return new Imagine();
29
        }
30
31
        throw new Exception('Gmagick and Imagick are missing, install one of those module');
32
    }
33
}
34