Files
kiri-core/http-message/Parse.php
T
2021-09-10 13:58:29 +08:00

36 lines
621 B
PHP

<?php
namespace Protocol\Message;
use Kiri\Core\Xml;
class Parse
{
/**
* @param $content
* @param $contentType
* @return mixed
*/
public static function data($content, $contentType): mixed
{
if (str_contains($contentType, 'json')) {
return json_encode($content);
}
var_dump($contentType);
if (str_contains($contentType, 'xml')) {
return Xml::toArray($content);
}
if (str_contains($contentType, 'x-www-form-urlencoded')) {
parse_str($content, $array);
return $array;
}
if (str_contains($contentType, 'serialize')) {
return unserialize($content);
}
return $content;
}
}