當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Base\Assert類代碼示例

本文整理匯總了PHP中Hesper\Core\Base\Assert的典型用法代碼示例。如果您正苦於以下問題:PHP Assert類的具體用法?PHP Assert怎麽用?PHP Assert使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Assert類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import

 public function import($scope)
 {
     if (!$this->className) {
         throw new WrongStateException("no class defined for PrimitiveUuidIdentifierList '{$this->name}'");
     }
     if (!BasePrimitive::import($scope)) {
         return null;
     }
     if (!is_array($scope[$this->name])) {
         return false;
     }
     $list = array_unique($scope[$this->name]);
     $values = array();
     foreach ($list as $id) {
         if (!Assert::checkUUID($id)) {
             return false;
         }
         $values[] = $id;
     }
     $objectList = $this->dao()->getListByIds($values);
     if (count($objectList) == count($values) && !($this->min && count($values) < $this->min) && !($this->max && count($values) > $this->max)) {
         $this->value = $objectList;
         return true;
     }
     return false;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:26,代碼來源:PrimitiveUuidIdentifierList.php

示例2: isIndexExists

 public static function isIndexExists($array, $key, $message = null)
 {
     Assert::isArray($array);
     if (!array_key_exists($key, $array)) {
         throw new WrongArgumentException($message . ', ' . self::dumpArgument($key));
     }
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:7,代碼來源:Assert.php

示例3: 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

示例4: rebind

 public function rebind($name, $object)
 {
     Assert::isNotNull($object);
     $this->map[$name] = $object;
     $this->reverseMap[spl_object_hash($object)] = $name;
     return $this;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:7,代碼來源:DirectoryContext.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: import

 public function import($scope)
 {
     if (!$this->className) {
         throw new WrongStateException("no class defined for PrimitiveIdentifierList '{$this->name}'");
     }
     if (!BasePrimitive::import($scope)) {
         return null;
     }
     if (!is_array($scope[$this->name])) {
         return false;
     }
     $list = array_unique($scope[$this->name]);
     $values = array();
     foreach ($list as $id) {
         if (!Assert::checkScalar($id)) {
             return false;
         }
         $values[] = $id;
     }
     $objectList = array();
     foreach ($values as $value) {
         $className = $this->className;
         $objectList[] = new $className($value);
     }
     if (count($objectList) == count($values)) {
         $this->value = $objectList;
         return true;
     }
     return false;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:30,代碼來源:PrimitiveRegistryList.php

示例7: 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

示例8: 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

示例9: setPublic

 /**
  * @return DoctypeDeclaration
  **/
 public function setPublic($isPublic)
 {
     Assert::isBoolean($isPublic);
     $this->public = $isPublic;
     $this->inline = false;
     return $this;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:10,代碼來源:DoctypeDeclaration.php

示例10: setAllowableTags

 /**
  * @return StripTagsFilter
  **/
 public function setAllowableTags($exclude)
 {
     if (null !== $exclude) {
         Assert::isString($exclude);
     }
     $this->exclude = $exclude;
     return $this;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:11,代碼來源:StripTagsFilter.php

示例11: addTable

 /**
  * @throws WrongArgumentException
  * @return DBSchema
  **/
 public function addTable(DBTable $table)
 {
     $name = $table->getName();
     Assert::isFalse(isset($this->tables[$name]), "table '{$name}' already exist");
     $this->tables[$table->getName()] = $table;
     $this->order[] = $name;
     return $this;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:12,代碼來源:DBSchema.php

示例12: getRequestGetter

 public function getRequestGetter()
 {
     Assert::isNotNull($this->requestType);
     if (!$this->requestGetter) {
         $this->requestGetter = self::$requestGetterMap[$this->requestType->getId()];
     }
     return $this->requestGetter;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:8,代碼來源:ProxyController.php

示例13: 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

示例14: getOpenPoint

 /**
  * @throws WrongArgumentException
  * @return LogicalChain
  **/
 public static function getOpenPoint($left, $right, $point)
 {
     Assert::isFalse($point === null, 'how can i build logic from emptyness?');
     $point = new DBValue($point);
     $chain = new LogicalChain();
     $chain->expOr(Expression::orBlock(Expression::andBlock(Expression::notNull($left), Expression::notNull($right), Expression::between($point, $left, $right)), Expression::andBlock(Expression::isNull($left), Expression::ltEq($point, $right)), Expression::andBlock(Expression::isNull($right), Expression::ltEq($left, $point)), Expression::andBlock(Expression::isNull($left), Expression::isNull($right))));
     return $chain;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:12,代碼來源:LogicUtils.php

示例15: prepareResponseFormat

 protected function prepareResponseFormat()
 {
     if ($this->request->hasAttachedVar('format')) {
         Assert::isNotFalse(array_search($this->request->getAttachedVar('format'), $this->allowedFormatList));
     } else {
         $this->request->setAttachedVar('format', self::DEFAULT_FORMAT);
     }
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:8,代碼來源:SimpleFrontController.php


注:本文中的Hesper\Core\Base\Assert類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。