Discovery   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 0 10 3
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