本文整理汇总了PHP中data::asString方法的典型用法代码示例。如果您正苦于以下问题:PHP data::asString方法的具体用法?PHP data::asString怎么用?PHP data::asString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data
的用法示例。
在下文中一共展示了data::asString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Retrieves hash on an object descriptor and its related secret information.
*
* @param string $object some public object hash is to be used for (e.g. a user's name)
* @param string $secret some internal-only information related to that object (e.g. the user's internal ID or similar)
* @return string
* @throws \InvalidArgumentException on missing/invalid object or secret
*/
public static function get($object, $secret)
{
$object = trim(data::asString($object));
$secret = trim(data::asString($secret));
if ($object === '' || $secret === '') {
throw new \InvalidArgumentException('missing/invalid hashing data');
}
return static::_get($object, $secret, time());
}
示例2: items
/**
* Fetches items matching all previous criteria.
*
* @return array[array] items fetched from datasource
*/
public function items()
{
if ($this->_sortBy) {
$property = $this->_sortBy[0];
$ascending = $this->_sortBy[1];
uasort($this->_items, function ($left, $right) use($property, $ascending) {
if (!is_array($left)) {
$left = null;
} else {
if (!array_key_exists($property, $left)) {
$left = null;
} else {
$left = data::asString($left[$property]);
}
}
if (!is_array($right)) {
$right = null;
} else {
if (!array_key_exists($property, $right)) {
$right = null;
} else {
$right = data::asString($right[$property]);
}
}
if ($left === null && $right === null) {
return 0;
}
if ($right === null) {
$result = 1;
} else {
if ($left === null) {
$result = -1;
} else {
$result = strcasecmp($left, $right);
}
}
return $ascending ? $result : -$result;
});
}
if ($this->_window['size'] > 0) {
return array_slice($this->_items, $this->_window['offset'], $this->_window['size'], true);
}
return array_slice($this->_items, $this->_window['offset'], null, true);
}
示例3: wrap
/**
* Retrieves provided content wrapped in content of current capture buffer.
*
* @param mixed $strContent content to be wrapped, gets converted to string
* internally using data::asString()
* @return string
*/
public function wrap($strContent)
{
return str_replace(static::middleMarker, data::asString($strContent), $this->_captured);
}