本文整理汇总了PHP中Params::arrayToObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Params::arrayToObject方法的具体用法?PHP Params::arrayToObject怎么用?PHP Params::arrayToObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Params
的用法示例。
在下文中一共展示了Params::arrayToObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate()
{
$gateway = new $this->provider();
Params::arrayToObject($this, $gateway);
return $gateway->validate();
}
示例2: merge
/**
* Merges the current object with the specified associtive array. Colon properties will
* be marked up to their respective objects. For instance, if your object is
*
* class X extends RequestObject
* {
* public $objProp;
* }
*
* and the $with is
*
* objProp:value1
*
* then $this->objProp->value1 will be set accordingly.
*
* @param array $with an associtive array of items to merge
* @return void
*/
public function merge(&$with)
{
Params::arrayToObject($with, $this);
$objs = array();
foreach ($with as $key => $value) {
$m = array();
if (preg_match('/^(\\w+)[:](\\w+)/', $key, $m)) {
$oKey = $m[1];
$pKey = $m[2];
if (!array_key_exists($oKey, $objs)) {
$objs[$oKey] = array();
}
$objs[$oKey][$pKey] = $value;
}
}
if (count($objs)) {
foreach ($objs as $prop => $desc) {
Params::arrayToObject($desc, $this->{$prop});
}
}
}