1 | <?php |
||
11 | class IniParser implements ParserInterface |
||
12 | { |
||
13 | /** |
||
14 | * {@inheritdoc} |
||
15 | */ |
||
16 | public function parse($file) |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public function dump($file, array $data) |
||
33 | |||
34 | /** |
||
35 | * Writes an array configuration to a INI string and returns it. |
||
36 | * The array provided must be multidimensional, indexed by section names: |
||
37 | * ``` |
||
38 | * array( |
||
39 | * 'Section 1' => array( |
||
40 | * 'value1' => 'hello', |
||
41 | * 'value2' => 'world', |
||
42 | * ), |
||
43 | * 'Section 2' => array( |
||
44 | * 'value3' => 'foo', |
||
45 | * ) |
||
46 | * ); |
||
47 | * ``` |
||
48 | * @link https://github.com/piwik/component-ini/blob/master/src/IniWriter.php |
||
49 | * @param array $config |
||
50 | * @param string $header Optional header to insert at the top of the file. |
||
51 | * @return string |
||
52 | */ |
||
53 | public static function writeToString(array $config, $header = '') |
||
83 | |||
84 | /** |
||
85 | * Formats value |
||
86 | * @param $value |
||
87 | * @return int|string |
||
88 | */ |
||
89 | protected static function escapeValue($value) |
||
90 | { |
||
91 | if (is_bool($value)) { |
||
92 | return (int) $value; |
||
93 | } |
||
94 | if (is_string($value)) { |
||
95 | return "\"$value\""; |
||
96 | } |
||
97 | return $value; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public static function getSupportedExtensions() |
||
107 | } |
||
108 |
If you suppress an error, we recommend checking for the error condition explicitly: