本文整理汇总了PHP中Hesper\Core\Base\Assert::checkScalar方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::checkScalar方法的具体用法?PHP Assert::checkScalar怎么用?PHP Assert::checkScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hesper\Core\Base\Assert
的用法示例。
在下文中一共展示了Assert::checkScalar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
public function import($scope)
{
if (!$this->className) {
throw new WrongStateException("no class defined for PrimitiveIdentifierList '{$this->name}'");
}
if (!BasePrimitive::import($scope)) {
return null;
}
if (!is_array($scope[$this->name])) {
return false;
}
$list = array_unique($scope[$this->name]);
$values = array();
foreach ($list as $id) {
if (!Assert::checkScalar($id)) {
return false;
}
$values[] = $id;
}
$objectList = array();
foreach ($values as $value) {
$className = $this->className;
$objectList[] = new $className($value);
}
if (count($objectList) == count($values)) {
$this->value = $objectList;
return true;
}
return false;
}
示例2: import
public function import($scope)
{
if (!$this->className) {
throw new WrongStateException("no class defined for PrimitiveIdentifierList '{$this->name}'");
}
if (!BasePrimitive::import($scope)) {
return null;
}
if (!is_array($scope[$this->name])) {
return false;
}
$list = array_unique($scope[$this->name]);
$values = [];
foreach ($list as $id) {
if ((string) $id == "" && $this->isIgnoreEmpty()) {
continue;
}
if ($this->scalar && !Assert::checkScalar($id) || !$this->scalar && !Assert::checkInteger($id)) {
if (!$this->isIgnoreWrong()) {
return false;
} else {
continue;
}
//just skip it
}
$values[] = $id;
}
$objectList = $this->dao()->getListByIds($values);
if ((count($objectList) == count($values) || $this->isIgnoreWrong()) && !($this->min && count($values) < $this->min) && !($this->max && count($values) > $this->max)) {
$this->value = $objectList;
return true;
}
return false;
}