當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。