16
16
use Toolkit \FsUtil \Exception \IOException ;
17
17
use Toolkit \FsUtil \Parser \IniParser ;
18
18
use Toolkit \FsUtil \Parser \JsonParser ;
19
- use Toolkit \FsUtil \Parser \YamlParser ;
20
19
use Toolkit \FsUtil \Traits \FileOperateTrait ;
21
20
use Toolkit \FsUtil \Traits \FileSnippetReadTrait ;
22
21
use function dirname ;
@@ -83,11 +82,6 @@ public static function parse(string $src, string $format = self::FORMAT_PHP): ar
83
82
{
84
83
$ src = trim ($ src );
85
84
switch ($ format ) {
86
- case self ::FORMAT_YML :
87
- case self ::FORMAT_YAML :
88
- $ array = self ::parseYaml ($ src );
89
- break ;
90
-
91
85
case self ::FORMAT_JSON :
92
86
$ array = self ::parseJson ($ src );
93
87
break ;
@@ -97,9 +91,10 @@ public static function parse(string $src, string $format = self::FORMAT_PHP): ar
97
91
break ;
98
92
99
93
case self ::FORMAT_PHP :
100
- default :
101
- $ array = self ::loadPhp ($ src );
94
+ $ array = self ::loadPhpFile ($ src );
102
95
break ;
96
+ default :
97
+ throw new InvalidArgumentException ('unsupported format ' . $ format );
103
98
}
104
99
105
100
return $ array ;
@@ -114,7 +109,7 @@ public static function parse(string $src, string $format = self::FORMAT_PHP): ar
114
109
* @return array
115
110
* @throws FileNotFoundException
116
111
*/
117
- public static function loadPhp (string $ file , bool $ throwError = true ): array
112
+ public static function loadPhpFile (string $ file , bool $ throwError = true ): array
118
113
{
119
114
$ ary = [];
120
115
@@ -172,27 +167,6 @@ public static function loadIni(string $fileOrContents): array
172
167
return IniParser::parse ($ fileOrContents );
173
168
}
174
169
175
- /**
176
- * @param string $fileOrContents 要解析的 yml 文件名 或 字符串内容。
177
- *
178
- * @return array
179
- */
180
- public static function parseYaml (string $ fileOrContents ): array
181
- {
182
- return YamlParser::parse ($ fileOrContents );
183
- }
184
-
185
- /**
186
- * @param string $fileOrContents 要解析的 yml 文件名 或 字符串内容。
187
- *
188
- * @return array
189
- * @deprecated please use parseYaml()
190
- */
191
- public static function loadYaml (string $ fileOrContents ): array
192
- {
193
- return YamlParser::parse ($ fileOrContents );
194
- }
195
-
196
170
/**********************************************************************************
197
171
* php function wrapper, add error handle
198
172
*********************************************************************************/
0 commit comments