1 | <?php |
||
9 | class Parser extends SymfonyYamlParser |
||
10 | { |
||
11 | /** @var array */ |
||
12 | protected static $functions = []; |
||
13 | |||
14 | /** |
||
15 | * @param string $id |
||
16 | * @param callable $callable |
||
17 | */ |
||
18 | public static function registerFunction($id, $callable) |
||
19 | { |
||
20 | static::$functions[$id] = $callable; |
||
21 | } |
||
22 | |||
23 | public static function registerFileFunction() |
||
24 | { |
||
25 | static::registerFunction('file', function($fileName) { |
||
26 | return file_get_contents($fileName); |
||
27 | }); |
||
28 | } |
||
29 | |||
30 | public static function registerDateFunction() |
||
31 | { |
||
32 | static::registerFunction('date', function($date = null) { |
||
33 | return new \DateTime($date); |
||
34 | }); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param string $value |
||
39 | * @param int $flags |
||
40 | * @return array|null |
||
41 | */ |
||
42 | public function parse($value, $flags = 0) |
||
52 | |||
53 | /** |
||
54 | * @param array $values |
||
55 | * @return $this |
||
56 | * @throws \Exception |
||
57 | */ |
||
58 | protected function parseValues(array &$values) |
||
92 | } |
||
93 |