1 | <?php |
||
35 | class Toml extends AbstractFileParser |
||
36 | { |
||
37 | /** |
||
38 | * Loads a TOML file as an array. |
||
39 | * |
||
40 | * @param string $path File path |
||
41 | * |
||
42 | * @throws ParseException If there is an error parsing TOML file |
||
43 | * |
||
44 | * @return array The parsed data |
||
45 | * |
||
46 | * @since 0.1.0 |
||
47 | */ |
||
48 | 6 | public function parse($path) |
|
49 | { |
||
50 | 6 | $data = null; |
|
51 | |||
52 | 1 | try { |
|
53 | 6 | $data = $this->loadFile($path); |
|
54 | 4 | } catch (Exception $ex) { |
|
55 | 3 | throw new ParseException( |
|
56 | [ |
||
57 | 3 | 'message' => 'Error parsing TOML file', |
|
58 | 3 | 'file' => $path, |
|
59 | 3 | 'exception' => $ex, |
|
60 | ] |
||
61 | 1 | ); |
|
62 | } |
||
63 | |||
64 | 3 | return $data; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | * |
||
70 | * @return array Supported extensions |
||
71 | * |
||
72 | * @since 0.1.0 |
||
73 | */ |
||
74 | 3 | public function getSupportedFileExtensions() |
|
78 | |||
79 | /** |
||
80 | * Loads in the given file and parses it. |
||
81 | * |
||
82 | * @param string $file File to load |
||
83 | * |
||
84 | * @return array The parsed file data |
||
85 | * |
||
86 | * @since 0.2.4 |
||
87 | * @codeCoverageIgnore |
||
88 | */ |
||
89 | protected function loadFile($file = null) |
||
96 | |||
97 | /** |
||
98 | * Returns the formatted configuration file contents. |
||
99 | * |
||
100 | * @param array $contents configuration array |
||
101 | * |
||
102 | * @return string formatted configuration file contents |
||
103 | * |
||
104 | * @since 0.2.4 |
||
105 | * @codeCoverageIgnore |
||
106 | */ |
||
107 | protected function exportFormat($contents = null) |
||
113 | |||
114 | /** |
||
115 | * __toString. |
||
116 | * |
||
117 | * @return string |
||
118 | * @since 0.1.2 |
||
119 | * @codeCoverageIgnore |
||
120 | */ |
||
121 | public function __toString() |
||
125 | } |
||
126 | |||
128 |