This commit is contained in:
2021-09-10 10:24:11 +08:00
parent c02da89654
commit dca5d3e6ec
8 changed files with 955 additions and 957 deletions
+22 -22
View File
@@ -8,27 +8,27 @@ class Parse
{
/**
* @param $content
* @param $contentType
* @return mixed
*/
public static function data($content, $contentType): mixed
{
if (str_contains($contentType, 'json')) {
return json_encode($contentType);
}
if (str_contains($contentType, 'xml')) {
return Xml::toArray($contentType);
}
if (str_contains($contentType, 'x-www-form-urlencoded')) {
parse_str($content, $array);
return $array;
}
if (str_contains($contentType, 'serialize')) {
return unserialize($content);
}
return $content;
}
/**
* @param $content
* @param $contentType
* @return mixed
*/
public static function data($content, $contentType): mixed
{
if (str_contains($contentType, 'json')) {
return json_encode($contentType);
}
if (str_contains($contentType, 'xml')) {
return Xml::toArray($contentType);
}
if (str_contains($contentType, 'x-www-form-urlencoded')) {
parse_str($content, $array);
return $array;
}
if (str_contains($contentType, 'serialize')) {
return unserialize($content);
}
return $content;
}
}