本文整理汇总了PHP中Assert::isScalarOrNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isScalarOrNull方法的具体用法?PHP Assert::isScalarOrNull怎么用?PHP Assert::isScalarOrNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert
的用法示例。
在下文中一共展示了Assert::isScalarOrNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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;
}
示例2: __construct
function __construct($title = null, $block = false)
{
Assert::isScalarOrNull($title);
Assert::isBoolean($block);
$this->title = $title;
$this->block = $block;
}
示例3: quoteValue
function quoteValue($value)
{
Assert::isScalarOrNull($value, 'not a scalar, but %s', gettype($value));
if (is_null($value)) {
return 'NULL';
}
return '\'' . mysql_real_escape_string($value, $this->link) . '\'';
}
示例4: quoteValue
function quoteValue($value)
{
Assert::isScalarOrNull($value);
if (is_null($value)) {
return 'NULL';
}
return "'" . str_replace("'", "''", $value) . "'";
}
示例5: __construct
/**
* @param string $filepath path to the file that should be presented in response
* @param string $filename optional name of the file to be specified in the response
* @param string $contentType optional content type of the file to be specified in the response
* @param boolean $unlinkOnFinish whether to remove the file when response is finished
*/
function __construct($filepath, $filename = null, $contentType = null, $unlinkOnFinish = false)
{
Assert::isTrue(is_file($filepath));
Assert::isScalarOrNull($filename);
Assert::isScalarOrNull($contentType);
Assert::isBoolean($unlinkOnFinish);
$this->filepath = $filepath;
$this->filename = $filename ? $filename : basename($filepath);
$this->contentType = $contentType;
$this->unlinkOnFileFlush = $unlinkOnFinish;
}
示例6: quoteValue
function quoteValue($value)
{
Assert::isScalarOrNull($value, 'not a scalar, but %s', gettype($value));
if (is_null($value)) {
return 'NULL';
}
if (is_bool($value)) {
$value = $value ? 't' : 'f';
}
return "'" . pg_escape_string($value) . "'";
}
示例7: __construct
/**
* @param IQueryable $entity entity to use as base when guessing path to queried properties
* @param string $alias optional table label
*/
function __construct(IQueryable $entity, $alias = null)
{
Assert::isScalarOrNull($alias);
$this->entity = $entity;
$this->table = $entity->getPhysicalSchema()->getTable();
$this->alias = $alias ? $alias : $this->table;
$this->registeredIds[$this->table] = true;
if ($alias) {
$this->registeredIds[$alias] = true;
}
$this->joins[] = new SelectQuerySource(new AliasedSqlValueExpression(new SqlIdentifier($this->table), $alias));
}
示例8: getDir
/**
* @return string
*/
private function getDir($class, $scope, $internalDirectory = null)
{
Assert::isScalarOrNull($internalDirectory);
$absolutePath = array($scope, $this->getActualClassName($class));
if ($internalDirectory) {
$absolutePath[] = (string) $internalDirectory;
}
$absolutePath = join(DIRECTORY_SEPARATOR, $absolutePath);
if (!is_dir($absolutePath)) {
mkdir($absolutePath, 0755, true);
}
Assert::isTrue(is_writable($absolutePath), 'directory %s is not writable', $absolutePath);
return $absolutePath;
}
示例9: setDbSchema
/**
* Sets the name of the database schema (defined within DBPool) where an entity should be
* stored
*
* @param strign $dbSchema optional name of the database schema. NULL to set the default schema
*
* @return OrmClass itself
*/
function setDbSchema($dbSchema = null)
{
Assert::isScalarOrNull($dbSchema);
$this->dbSchema = $dbSchema;
return $this;
}
示例10: route
/**
* Smart route assembler.
*
* Accepts the name of the route to be assembled, URI to be used as a template for the rules.
*
* Example:
* @code
* $router->route("blogEntry", "/blog:controller/entry:action/?id");
* @endcode
*
* In future, the third parameter will be allowed to contain various objects that will be
* smartly mapped to appropriate rules.
*
* @param string $name name of the route
* @param string $uri URI that will be used as request variables template
* @param array $parameters array of parameters to be appended to Trace
* @return ChainedRouter itself
*/
function route($name, $uri = null, array $parameters = array())
{
Assert::isScalar($name);
Assert::isScalarOrNull($uri);
$rules = array();
if ($uri) {
$parsedUrlPattern = parse_url($uri);
if (isset($parsedUrlPattern['path'])) {
$rules[] = new PathRewriteRule($parsedUrlPattern['path']);
}
if (isset($parsedUrlPattern['query'])) {
$queryStringVariables = array();
parse_str($parsedUrlPattern['query'], $queryStringVariables);
foreach ($queryStringVariables as $qsVar => $qsValue) {
$rules[] = new RequestVarImportRule($qsVar, new WebRequestPart(WebRequestPart::GET), !empty($qsValue), empty($qsValue) ? null : $qsValue);
}
}
}
foreach ($parameters as $parameter => $value) {
$rules[] = new ParameterImportRule($parameter, $value);
}
$this->addRoute($name, new Route($this->defaultDispatcher, $rules));
return $this;
}
示例11: setVersion
/**
* @return DoxyGroup
*/
function setVersion($version = null)
{
Assert::isScalarOrNull($version);
$this->version = $version;
return $this;
}
示例12: __construct
function __construct($activeElement = null)
{
Assert::isScalarOrNull($activeElement);
$this->activeElement = $activeElement;
parent::__construct('parts/top-menu');
}
示例13: setSubdomain
/**
* Sets the subdomain prepending it to the base host
*
* @param string|null $subdomain host to be treated as subdomain, or NULL if need
* to drop the subdomain
*
* @return SiteUrl itself
*/
function setSubdomain($subdomain = null)
{
Assert::isScalarOrNull($subdomain);
$host = $subdomain ? $subdomain . '.' . $this->baseHost : $this->baseHost;
$this->setHost($host);
return $this;
}
示例14: __construct
/**
* @param string $content texutal data to be passed to response
*/
function __construct($content = null)
{
Assert::isScalarOrNull($content);
$this->content = $content;
}
示例15: getOption
/**
* Gets the <option> tag as string
* @param $value
* @param $selected
* @return string
*/
protected function getOption($value, $selected)
{
Assert::isScalarOrNull($value);
Assert::isBoolean($selected);
$attributes = array();
if ($value) {
$attributes['value'] = $value;
}
if ($selected) {
$attributes['selected'] = 'selected';
}
return HtmlUtil::getContainer('option', $attributes, $this->getLabelFor($value));
}