本文整理汇总了PHP中Assert::isScalar方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isScalar方法的具体用法?PHP Assert::isScalar怎么用?PHP Assert::isScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert
的用法示例。
在下文中一共展示了Assert::isScalar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($name, $address)
{
Assert::isScalar($name);
Assert::isScalar($address);
$this->name = $name;
$this->address = $address;
}
示例2: move
function move($filepath)
{
Assert::isScalar($filepath);
Assert::isTrue(is_dir(dirname($filepath)));
Assert::isTrue(is_writable(dirname($filepath)));
return move_uploaded_file($this->getImportedFilepath(), $filepath);
}
示例3: importValue
public function importValue($value)
{
if ($value instanceof UnifiedContainer) {
if ($value->isLazy()) {
return $this->import(array($this->name => $value->getList()));
} elseif ($value->getParentObject()->getId() && ($list = $value->getList())) {
return $this->import(array($this->name => ArrayUtils::getIdsArray($list)));
} else {
return parent::importValue(null);
}
}
if (is_array($value)) {
try {
if ($this->scalar) {
Assert::isScalar(current($value));
} else {
Assert::isInteger(current($value));
}
return $this->import(array($this->name => $value));
} catch (WrongArgumentException $e) {
return $this->import(array($this->name => ArrayUtils::getIdsArray($value)));
}
}
return parent::importValue($value);
}
示例4: __construct
/**
* @param ISqlQuery $query
* @param string $errormsg
* @param integer $errorno
*/
function __construct(ISqlQuery $query, $errormsg, $errorno)
{
Assert::isScalar($errormsg);
Assert::isNumeric($errorno);
parent::__construct($errormsg, $errorno);
$this->query = $query;
}
示例5: setPattern
/**
* Sets the new URL pattern to use
*
* @param string $pattern pattern to set
*
* @return PathRewriteRule itself
*/
function setPattern($pattern)
{
Assert::isScalar($pattern);
$this->urlPattern = '/' . ltrim($pattern, '/');
$this->parsePattern();
return $this;
}
示例6: __construct
function __construct($name, $label)
{
Assert::isScalar($name);
Assert::isScalar($label);
$this->name = $name;
$this->label = $label;
}
示例7: __construct
/**
* @param string $name name of the column
* @param ISqlType $type SQL type of the column
*/
function __construct($name, DBTable $table, ISqlType $type)
{
Assert::isScalar($name);
$this->name = $name;
$this->table = $table;
$this->type = $type;
}
示例8: setDefaultValue
function setDefaultValue($value)
{
Assert::isScalar($value, 'default value shall be scalar');
Assert::isTrue(in_array($value, $this->getAvailableValues()), 'trying to set a default value that is out of options range');
$this->defaultValue = $value;
return $this;
}
示例9: __construct
/**
* @param string $func name of the aggregate
* @param string $expression property to be used for aggregation
* @param string $alias optional label for the result of the aggregator
*/
function __construct($func, $expression = null, $alias = null)
{
Assert::isScalar($func);
$this->func = $func;
$this->expression = $expression;
$this->alias = $alias;
}
示例10: __construct
/**
* @param string $field name of the column
* @param string $table optional name of the table that owns the column
*/
function __construct($field, $table = null)
{
Assert::isScalar($field);
Assert::isScalarOrNull($table);
$this->field = $field;
$this->table = $table;
}
示例11: __construct
function __construct($title, $name)
{
Assert::isScalar($title);
Assert::isScalar($name);
$this->title = $title;
$this->name = $name;
}
示例12: __construct
/**
* @param WebRequestDictionary $dictonary
* @param array $getVars request's $_GET
* @param array $postVars request's $_POST
* @param array $cookieVars request's $_COOKIE
* @param array $filesVars request's $_FILES
* @param string|null $baseHost optional base host for request's request url (SiteUrl)
* @param string $baseUri optional base uri
*/
function __construct(WebRequestDictionary $dictonary, array $getVars, array $postVars, array $cookieVars, array $filesVars, $baseHost = null, $baseUri = '/')
{
Assert::isScalar($baseUri);
$this->dictionary = $dictonary->getFields();
$this->httpUrl = SiteUrl::import($dictonary, $baseHost, $baseUri);
$this->vars = array(WebRequestPart::GET => $getVars, WebRequestPart::POST => $postVars, WebRequestPart::COOKIE => $cookieVars, WebRequestPart::FILES => $filesVars);
$this->allVars = call_user_func_array('array_merge', array($filesVars, $cookieVars, $postVars, $getVars));
}
示例13: __construct
/**
* @throws FileNotFoundException thrown when the path to a file is wrong
* @param string $layoutPath path to PHP file
*/
function __construct($layoutPath)
{
Assert::isScalar($layoutPath);
$this->layoutPath = $layoutPath;
if (!file_exists($layoutPath)) {
throw new FileNotFoundException($layoutPath, 'template not found at the specified path');
}
}
示例14: getTable
/**
* Gets the DBTable object by its name
*
* @param string $name name of the table to look up
* @throws ArgumentException thrown when no DBTable object identified by name found
* @return DBTable
*/
function getTable($name)
{
Assert::isScalar($name);
if (!isset($this->tables[$name])) {
throw new ArgumentException('name', 'not found');
}
return $this->tables[$name];
}
示例15: __construct
/**
* @param array of string $fields
*/
function __construct($name, DBTable $table, array $fields)
{
Assert::isScalar($name);
Assert::isNotEmpty($fields, 'constraint cannot be across zero fields');
$this->name = $name;
$this->table = $table;
$this->fields = $fields;
}