mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-08 05:18:40 +00:00
Add getter for json and list data
This commit is contained in:
parent
23f31d359a
commit
378a569316
|
|
@ -172,6 +172,51 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
return $this->data[$key] ?? null;
|
return $this->data[$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data.
|
||||||
|
*
|
||||||
|
* @param mixed $key Data key
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getDataJson($key) : array
|
||||||
|
{
|
||||||
|
$key = \mb_strtolower($key);
|
||||||
|
|
||||||
|
if (!isset($this->data[$key])) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = \json_decode($this->data[$key]);
|
||||||
|
|
||||||
|
return $json === false ? [] : $json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data.
|
||||||
|
*
|
||||||
|
* @param mixed $key Data key
|
||||||
|
* @param string $delim Data delimiter
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getDataList($key, string $delim = ',') : array
|
||||||
|
{
|
||||||
|
$key = \mb_strtolower($key);
|
||||||
|
|
||||||
|
if (!isset($this->data[$key])) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$list = \explode($delim, $this->data[$key]);
|
||||||
|
|
||||||
|
return $list === false ? [] : $json;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data based on wildcard.
|
* Get data based on wildcard.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user