5 use function class_exists
;
7 abstract class Formatter
{
8 abstract function formatString(string $string) : string;
9 abstract function formatFile(string $file) : string;
11 static function factory() : Formatter
{
12 if (class_exists("League\\CommonMark\\GithubFlavoredMarkdownConverter", true)) {
13 return new Formatter\League
;
15 if (extension_loaded("discount")) {
16 return new Formatter\Discount
;
18 throw new \
Exception("No Markdown implementation found");