本文整理汇总了PHP中Assert::isTrue方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isTrue方法的具体用法?PHP Assert::isTrue怎么用?PHP Assert::isTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert
的用法示例。
在下文中一共展示了Assert::isTrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: of
/**
* @throws WrongArgumentException
* @return PrimitiveIdentifier
**/
public function of($class)
{
$className = $this->guessClassName($class);
Assert::isTrue(class_exists($className, true) || interface_exists($className, true), "knows nothing about '{$className}' class/interface");
$this->ofClassName = $className;
return $this;
}
示例2: __construct
/**
* @param OrmClass $ormClass object that represents a class to be generated
* @param OrmProperty $ormProperty property that implements a ContainerPropertyType
*/
function __construct(OrmClass $ormClass, OrmProperty $ormProperty)
{
$this->ormProperty = $ormProperty;
$this->propertyType = $ormProperty->getType();
Assert::isTrue($this->propertyType instanceof ContainerPropertyType);
parent::__construct($ormClass);
}
示例3: setValue
/**
* @throws WrongArgumentException
* @return IdentifiablePrimitive
**/
public function setValue($value)
{
$className = $this->className;
Assert::isNotNull($this->className);
Assert::isTrue($value instanceof $className);
return parent::setValue($value);
}
示例4: 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;
}
示例5: 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);
}
示例6: __construct
public function __construct()
{
require ONPHP_META_AUTO_DIR . 'schema.php';
Assert::isTrue(isset($schema));
$this->schema = $schema;
// in case of unclean shutdown of previous tests
foreach (DBTestPool::me()->getPool() as $name => $db) {
foreach ($this->schema->getTableNames() as $name) {
try {
$db->queryRaw(OSQL::dropTable($name, true)->toDialectString($db->getDialect()));
} catch (DatabaseException $e) {
// ok
}
if ($db->hasSequences()) {
foreach ($this->schema->getTableByName($name)->getColumns() as $columnName => $column) {
try {
if ($column->isAutoincrement()) {
$db->queryRaw("DROP SEQUENCE {$name}_id;");
}
} catch (DatabaseException $e) {
// ok
}
}
}
}
}
}
示例7: makeSelectQuery
private function makeSelectQuery(SqlSelectiveFieldSet $fields, $source, IDalExpression $condition = null, SqlOrderChain $orderBy = null, $limit = 0, $offset = 0)
{
Assert::isInteger($limit);
Assert::isInteger($offset);
$dialect = $this->getDB()->getDialect();
$query = array();
$query[] = 'SELECT ' . $fields->toDialectString($dialect);
if (is_scalar($source)) {
$source = $dialect->quoteIdentifier($source);
} else {
Assert::isTrue(is_array($source));
$tables = array();
foreach ($source as $table) {
$tables[] = $dialect->quoteIdentifier($table);
}
$source = join(", ", $tables);
}
$query[] = 'FROM ' . $source;
if ($condition) {
$query[] = 'WHERE ' . $condition->toDialectString($dialect);
}
if ($orderBy) {
$query[] = $orderBy->toDialectString($dialect);
}
if ($limit) {
$query[] = 'LIMIT ' . (int) $limit;
}
if ($offset) {
$query[] = 'OFFSET ' . (int) $offset;
}
$query = join("\r\n", $query);
return $query;
}
示例8: setValue
/**
* Sets the cookie value. It cannot be longer than Cookie::RFC_MAX_SIZE.
* @param string $value
* @return Cookie
*/
function setValue($value)
{
Assert::isScalar($value);
Assert::isTrue(strlen($value) < self::RFC_MAX_SIZE);
$this->value = $value;
return $this;
}
示例9: make
/**
* @return GmpBigInteger
**/
public static function make($number, $base = 10)
{
Assert::isTrue(is_numeric($number));
$result = new self();
$result->resource = gmp_init($number, $base);
return $result;
}
示例10: swap
public static function swap(DAOConnected $first, DAOConnected $second, $property = 'position')
{
Assert::isTrue(get_class($first) === get_class($second));
$setMethod = 'set' . ucfirst($property);
$getMethod = 'get' . ucfirst($property);
Assert::isTrue(method_exists($first, $setMethod) && method_exists($first, $getMethod));
$dao = $first->dao();
$db = DBPool::me()->getByDao($dao);
$oldPosition = $first->{$getMethod}();
$newPosition = $second->{$getMethod}();
$db->begin();
$e = null;
try {
$dao->save($first->{$setMethod}(self::$nullValue));
$dao->save($second->{$setMethod}($oldPosition));
$dao->save($first->{$setMethod}($newPosition));
$db->commit();
} catch (DatabaseException $e) {
$db->rollback();
}
$dao->uncacheByIds(array($first->getId(), $second->getId()));
if ($e) {
throw $e;
}
}
示例11: set
public function set($name, $value)
{
if (!isset($this->mapping[$name])) {
throw new WrongArgumentException("knows nothing about property '{$name}'");
}
$primitive = $this->mapping[$name];
$setter = 'set' . ucfirst($primitive->getName());
if (!method_exists($this->object, $setter)) {
throw new WrongArgumentException("cannot find mutator for '{$name}' in class " . get_class($this->object));
}
if (is_object($value)) {
if ($primitive instanceof PrimitiveAnyType && $value instanceof PrototypedEntity) {
$value = ObjectToDTOConverter::create($value->entityProto())->make($value);
} else {
$value = $this->dtoValue($value, $primitive);
}
} elseif (is_array($value) && is_object(current($value))) {
$dtoValue = array();
foreach ($value as $oneValue) {
Assert::isTrue(is_object($oneValue), 'array must contain only objects');
$dtoValue[] = $this->dtoValue($oneValue, $primitive);
}
$value = $dtoValue;
}
return $this->object->{$setter}($value);
}
示例12: cloneBuilder
/**
* @return PrototypedBuilder
**/
public function cloneBuilder(EntityProto $proto)
{
Assert::isTrue($this->proto->isInstanceOf($proto) || $proto->isInstanceOf($this->proto), Assert::dumpArgument($proto));
$result = new $this($proto);
$result->limitedPropertiesList = $this->limitedPropertiesList;
return $result;
}
示例13: __construct
function __construct(DBConnector $db)
{
Assert::isTrue(isset(self::$drivers[$db->getDriver()->getId()]), "unknown driver is specified: {$db->getDriver()}");
$className = self::$drivers[$db->getDriver()->getId()];
$driver = new ReflectionClass($className);
Assert::isTrue($driver->isSubclassOf(new ReflectionClass('DBBackup')), "{$className} should implement DBBackup");
$this->driver = $driver->newInstance($db);
}
示例14: __construct
public function __construct($left, $right, $logic)
{
Assert::isTrue($right instanceof Query || $right instanceof Criteria || $right instanceof MappableObject || is_array($right));
Assert::isTrue($logic == self::IN || $logic == self::NOT_IN);
$this->left = $left;
$this->right = $right;
$this->logic = $logic;
}
示例15: setDefault
/**
* @return PrimitiveMultiList
**/
public function setDefault($default)
{
Assert::isArray($default);
foreach ($default as $index) {
Assert::isTrue(array_key_exists($index, $this->list));
}
return parent::setDefault($default);
}