Discovery::find()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AmaTeam\Image\Projection\Image\Adapter;
4
5
use AmaTeam\Image\Projection\API\Image\ImageFactoryInterface;
6
use RuntimeException;
7
8
class Discovery
9
{
10
    const FACTORIES = [
11
        Gd\ImageFactory::class,
12
        Imagick\ImageFactory::class,
13
    ];
14
15
    /**
16
     * @return ImageFactoryInterface
17
     */
18
    public static function find()
19
    {
20
        foreach (self::FACTORIES as $backend) {
21
            if ($backend::supported()) {
22
                return new $backend;
23
            }
24
        }
25
        $message = 'Couldn\'t find any image processing backend, please ' .
26
            'install gd (preferred) / imagick.';
27
        throw new RuntimeException($message);
28
    }
29
}
30