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

ImagineFactory::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 9
cp 0
rs 10
cc 3
nc 3
nop 1
crap 12
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