Failed Conditions
Push — master ( f2bb18...5e6761 )
by Adrien
02:12
created

ImagineFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

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