1 | <?php |
||
9 | class ParserFactory |
||
10 | { |
||
11 | const EXTENSION_JSON = 'json'; |
||
12 | const EXTENSION_MD = 'markdown'; |
||
13 | const EXTENSION_FOLDER = 'folder'; |
||
14 | const EXTENSION_YML = 'yaml'; |
||
15 | const EXTENSION_YAML = 'yaml'; |
||
16 | const EXTENSION_IMG = 'image'; |
||
17 | const EXTENSION_JS = 'file'; |
||
18 | const EXTENSION_CSS = 'file'; |
||
19 | const EXTENSION_SASS = 'sass'; |
||
20 | const EXTENSION_SCSS = 'sass'; |
||
21 | const PARSER_DEFAULT = 'default'; |
||
22 | |||
23 | /** |
||
24 | * @var ContainerInterface |
||
25 | */ |
||
26 | private $container; |
||
27 | |||
28 | private static $typeFilters = []; |
||
29 | |||
30 | /** |
||
31 | * ParserFactory constructor. |
||
32 | * |
||
33 | * @param ContainerInterface $container |
||
34 | */ |
||
35 | public function __construct(ContainerInterface $container) { |
||
70 | |||
71 | /** |
||
72 | * @param string $type |
||
73 | * @param callable $filter |
||
74 | */ |
||
75 | public static function addTypeFilter(string $type, callable $filter) { |
||
78 | |||
79 | /** |
||
80 | * @param $fileName |
||
81 | * |
||
82 | * @return Parser|null |
||
83 | */ |
||
84 | public function getByFileName($fileName) : ?Parser { |
||
102 | |||
103 | /** |
||
104 | * @param string $type |
||
105 | * |
||
106 | * @return Parser|mixed |
||
107 | * @throws ParserException |
||
108 | */ |
||
109 | public function getByType($type) : Parser { |
||
118 | |||
119 | } |
||
120 |