1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4/**
5 * Factory for creating purifier instances
6 * @author Michael Jansen <mjansen@databay.de>
7 */
8class ilHtmlPurifierFactory
9{
10    /**
11     * Factory method for creating purifier instances
12     * @param string $type type for the concrete purifier instance
13     * @return ilHtmlPurifierInterface
14     * @throws ilHtmlPurifierNotFoundException
15     */
16    public static function _getInstanceByType(string $type) : ilHtmlPurifierInterface
17    {
18        global $DIC;
19
20        switch ($type) {
21            case 'frm_post':
22                return new ilHtmlForumPostPurifier();
23                break;
24
25            case 'qpl_usersolution':
26                return new ilAssHtmlUserSolutionPurifier();
27                break;
28        }
29
30        throw new ilHtmlPurifierNotFoundException(sprintf(
31            $DIC->language()->txt('frm_purifier_not_implemented_for_type_x'),
32            $type
33        ));
34    }
35}
36