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


PHP Assert::isTrue方法代码示例

本文整理汇总了PHP中Hesper\Core\Base\Assert::isTrue方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isTrue方法的具体用法?PHP Assert::isTrue怎么用?PHP Assert::isTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hesper\Core\Base\Assert的用法示例。


在下文中一共展示了Assert::isTrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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 = [];
         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:justthefish,项目名称:hesper,代码行数:26,代码来源:DTOSetter.php

示例2: 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:justthefish,项目名称:hesper,代码行数:10,代码来源:GmpBigInteger.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:justthefish,项目名称:hesper,代码行数:11,代码来源:IdentifiablePrimitive.php

示例4: 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:justthefish,项目名称:hesper,代码行数:10,代码来源:PrototypedBuilder.php

示例5: 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));
     /** @var StorableDAO $dao */
     $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([$first->getId(), $second->getId()]);
     if ($e) {
         throw $e;
     }
 }
开发者ID:justthefish,项目名称:hesper,代码行数:26,代码来源:DaoUtils.php

示例6: 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:justthefish,项目名称:hesper,代码行数:11,代码来源:PrimitiveClass.php

示例7: 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:justthefish,项目名称:hesper,代码行数:11,代码来源:PrimitiveMultiList.php

示例8: __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:justthefish,项目名称:hesper,代码行数:8,代码来源:InExpression.php

示例9: __construct

 public function __construct($class)
 {
     Assert::isTrue(ClassUtils::isInstanceOf($class, Prototyped::class));
     if (is_object($class)) {
         $this->className = get_class($class);
     } else {
         $this->className = $class;
     }
 }
开发者ID:justthefish,项目名称:hesper,代码行数:9,代码来源:ClassProjection.php

示例10: cacheListByQuery

 protected function cacheListByQuery(SelectQuery $query, $array)
 {
     if ($array !== Cache::NOT_FOUND) {
         Assert::isArray($array);
         Assert::isTrue(current($array) instanceof Identifiable);
     }
     Cache::me()->mark($this->className)->add($this->makeQueryKey($query, self::SUFFIX_LIST), $array, Cache::EXPIRES_FOREVER);
     return $array;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:9,代码来源:CacheDaoWorker.php

示例11: set

 public function set($name, $value)
 {
     if (!isset($this->mapping[$name])) {
         throw new WrongArgumentException("knows nothing about property '{$name}'");
     }
     Assert::isTrue(!is_object($value), 'cannot put objects into scope');
     $primitive = $this->mapping[$name];
     $this->object[$primitive->getName()] = $value;
     return $this;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:10,代码来源:ScopeSetter.php

示例12: toMapped

 /**
  * @return SQLChain
  **/
 public function toMapped(ProtoDAO $dao, JoinCapableQuery $query)
 {
     $size = count($this->chain);
     Assert::isTrue($size > 0, 'empty chain');
     $chain = new $this();
     for ($i = 0; $i < $size; ++$i) {
         $chain->exp($dao->guessAtom($this->chain[$i], $query), $this->logic[$i]);
     }
     return $chain;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:13,代码来源:SQLChain.php

示例13: offsetSet

 /**
  * @return IndexedList
  **/
 public function offsetSet($offset, $value)
 {
     Assert::isTrue($value instanceof Identifiable);
     $offset = $value->getId();
     if ($this->offsetExists($offset)) {
         throw new WrongArgumentException("object with id == '{$offset}' already exists");
     }
     $this->list[$offset] = $value;
     return $this;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:13,代码来源:IndexedList.php

示例14: cacheListByQuery

 protected function cacheListByQuery(SelectQuery $query, $array, $expires = Cache::EXPIRES_FOREVER)
 {
     if ($array !== Cache::NOT_FOUND) {
         Assert::isArray($array);
         Assert::isTrue(current($array) instanceof Identifiable);
     }
     $key = $this->makeQueryKey($query, self::SUFFIX_LIST);
     Cache::me()->mark($this->className)->set($key, ['tags' => $this->getTagsForQuery($query), 'data' => $array], $expires);
     //			SemaphorePool::me()->free(self::LOCK_PREFIX.$key);
     return $array;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:11,代码来源:TaggableDaoWorker.php

示例15: makeRandom

 /**
  * @return GmpBigInteger
  **/
 public function makeRandom($stop, RandomSource $source)
 {
     if (is_string($stop)) {
         $stop = $this->makeNumber($stop);
     } elseif ($stop instanceof BigInteger && !$stop instanceof GmpBigInteger) {
         $stop = $this->makeNumber($stop->toString());
     }
     Assert::isTrue($stop instanceof GmpBigInteger);
     $numBytes = ceil(log($stop->floatValue(), 2) / 8);
     return $this->makeFromBinary("" . $source->getBytes($numBytes))->mod($stop);
 }
开发者ID:justthefish,项目名称:hesper,代码行数:14,代码来源:GmpBigIntegerFactory.php


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