Grafika\Grafika::detectAvailableEditor PHP Method

detectAvailableEditor() public static method

Detects and return the name of the first supported editor which can either be "Imagick" or "Gd".
public static detectAvailableEditor ( array $editorList = null ) : string
$editorList array Array of editor list names. Use this to change the order of evaluation for editors for this function call only. Default order of evaluation is Imagick then GD.
return string Name of available editor.
    public static function detectAvailableEditor($editorList = null)
    {
        if (null === $editorList) {
            $editorList = self::$editorList;
        }
        /* Get first supported editor instance. Order of editorList matter. */
        foreach ($editorList as $editorName) {
            if ('Imagick' === $editorName) {
                $editorInstance = new ImagickEditor();
            } else {
                $editorInstance = new GdEditor();
            }
            /** @var EditorInterface $editorInstance */
            if (true === $editorInstance->isAvailable()) {
                return $editorName;
            }
        }
        throw new \Exception('No supported editor.');
    }