当前位置: 首页>>代码示例>>PHP>>正文


PHP Assert::isTrue方法代码示例

本文整理汇总了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;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:11,代码来源:PrimitiveClass.class.php

示例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);
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:11,代码来源:OrmContainerClassCodeConstructor.class.php

示例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);
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:11,代码来源:IdentifiablePrimitive.class.php

示例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;
 }
开发者ID:phoebus,项目名称:HTML_FormAbstraction,代码行数:7,代码来源:RadioFormControlSet.class.php

示例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);
 }
开发者ID:phoebus,项目名称:HTML_FormAbstraction,代码行数:7,代码来源:FileFormControl.class.php

示例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
                     }
                 }
             }
         }
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:27,代码来源:TestTables.class.php

示例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;
 }
开发者ID:phoebius,项目名称:proof-of-concept,代码行数:33,代码来源:QueryWorkbench.class.php

示例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;
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:12,代码来源:Cookie.class.php

示例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;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:10,代码来源:GmpBigInteger.class.php

示例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;
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:25,代码来源:DaoUtils.class.php

示例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);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:26,代码来源:DTOSetter.class.php

示例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;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:10,代码来源:PrototypedBuilder.class.php

示例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);
 }
开发者ID:phoebius,项目名称:proof-of-concept,代码行数:8,代码来源:DBDumper.class.php

示例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;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:8,代码来源:InExpression.class.php

示例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);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:11,代码来源:PrimitiveMultiList.class.php


注:本文中的Assert::isTrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。