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


PHP Assert::isInstance方法代码示例

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


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

示例1: generateLinks

 public static function generateLinks(array $classes)
 {
     $links = [];
     foreach ($classes as $class) {
         Assert::isInstance($class, 'MetaClass');
         foreach ($class->getProperties() as $property) {
             if ($property->getType() instanceof ObjectType && $property->getType()->getClassName() && $property->getRelation()) {
                 switch ($property->getRelation()->getId()) {
                     case MetaRelation::ONE_TO_ONE:
                         $rel = ' -- ';
                         break;
                     case MetaRelation::ONE_TO_MANY:
                         $rel = ' *-- ';
                         break;
                     case MetaRelation::MANY_TO_MANY:
                         $rel = ' *--* ';
                         break;
                     default:
                         throw new WrongStateException();
                         break;
                 }
                 $links[] = $class->getName() . $rel . $property->getType()->getClassName() . "\n";
             }
         }
         $links = array_unique($links);
     }
     return implode("", $links) . "\n";
 }
开发者ID:justthefish,项目名称:hesper,代码行数:28,代码来源:MetaClassPUMLGenerator.php

示例2: import

 public function import($scope)
 {
     if (!$this->className) {
         throw new WrongStateException("no class defined for PrimitiveIdentifier '{$this->name}'");
     }
     $className = $this->className;
     if (isset($scope[$this->name]) && $scope[$this->name] instanceof $className) {
         $value = $scope[$this->name];
         $this->raw = $value->getId();
         $this->setValue($value);
         return $this->imported = true;
     }
     $result = parent::import($scope);
     if ($result === true) {
         try {
             $result = $this->actualImportValue($this->value);
             Assert::isInstance($result, $className);
             $this->value = $result;
             return true;
         } catch (WrongArgumentException $e) {
             // not imported
         } catch (ObjectNotFoundException $e) {
             // not imported
         }
         $this->value = null;
         return false;
     }
     return $result;
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:29,代码来源:PrimitiveIdentifier.class.php

示例3: setSchemaPath

 /**
  * @param string $path
  * @return DBTestCreator
  */
 public function setSchemaPath($path)
 {
     require $path;
     Assert::isTrue(isset($schema));
     Assert::isInstance($schema, 'DBSchema');
     $this->schema = $schema;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:DBTestCreator.class.php

示例4: of

 /**
  * @throws WrongArgumentException
  * @return PrimitiveEnum
  **/
 public function of($class)
 {
     $className = $this->guessClassName($class);
     Assert::classExists($className);
     Assert::isInstance($className, 'Enum');
     $this->className = $className;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:PrimitiveEnum.class.php

示例5: send

 public function send(Message $message)
 {
     if (!$this->queue) {
         throw new WrongStateException('you must set the queue first');
     }
     Assert::isInstance($message, 'TextMessage');
     $this->getStream()->write($message->getTimestamp()->toString() . "\t" . str_replace(PHP_EOL, ' ', $message->getText()) . PHP_EOL);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:8,代码来源:TextFileSender.class.php

示例6: getBitmask

 public function getBitmask($config)
 {
     Assert::isInstance($config, 'AMQPExchangeConfig');
     $bitmask = parent::getBitmask($config);
     if ($config->getInternal()) {
         $bitmask = $bitmask | AMQP_INTERNAL;
     }
     return $bitmask;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:AMQPPeclExchangeBitmask.class.php

示例7: setValue

 /**
  * @return PrimitiveEnumList
  **/
 public function setValue($value)
 {
     if ($value) {
         Assert::isArray($value);
         Assert::isInstance(current($value), 'Enum');
     }
     $this->value = $value;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:PrimitiveEnumList.class.php

示例8: __construct

 public function __construct(Identifiable $parent, GenericDAO $dao, $lazy = true)
 {
     Assert::isBoolean($lazy);
     $this->parent = $parent;
     $this->lazy = $lazy;
     $this->dao = $dao;
     Assert::isInstance($dao->getObjectName(), 'Identifiable');
     $this->comparator = SerializedObjectComparator::me();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:UnifiedContainer.class.php

示例9: getBitmask

 public function getBitmask($config)
 {
     Assert::isInstance($config, 'AMQPQueueConfig');
     $bitmask = parent::getBitmask($config);
     if ($config->getExclusive()) {
         $bitmask = $bitmask | AMQP_EXCLUSIVE;
     }
     return $bitmask;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:AMQPPeclQueueBitmask.class.php

示例10: compare

 public function compare($one, $two)
 {
     Assert::isInstance($one, 'Identifiable');
     Assert::isInstance($two, 'Identifiable');
     $oneId = $one->getId();
     $twoId = $two->getId();
     if ($oneId === $twoId) {
         return 0;
     }
     return $oneId < $twoId ? -1 : 1;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:11,代码来源:ImmutableObjectComparator.class.php

示例11: addLink

 /**
  * @throws WrongArgumentException
  * @return AMQPPool
  **/
 public function addLink($name, AMQP $amqp)
 {
     if (isset($this->pool[$name])) {
         throw new WrongArgumentException("amqp link with name '{$name}' already registered");
     }
     if ($this->pool) {
         Assert::isInstance($amqp, current($this->pool));
     }
     $this->pool[$name] = $amqp;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:15,代码来源:AMQPSelective.class.php

示例12: compare

 public function compare($one, $two)
 {
     Assert::isInstance($one, 'Date');
     Assert::isInstance($two, 'Date');
     $stamp1 = $one->toStamp();
     $stamp2 = $two->toStamp();
     if ($stamp1 == $stamp2) {
         return 0;
     }
     return $stamp1 < $stamp2 ? -1 : 1;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:11,代码来源:DateObjectComparator.class.php

示例13: getBitmask

 public function getBitmask($config)
 {
     Assert::isInstance($config, 'AMQPOutgoingMessage');
     $bitmask = 0;
     if ($config->getMandatory()) {
         $bitmask = $bitmask | AMQP_MANDATORY;
     }
     if ($config->getImmediate()) {
         $bitmask = $bitmask | AMQP_IMMEDIATE;
     }
     return $bitmask;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:AMQPPeclOutgoingMessageBitmask.class.php

示例14: cloneInnerBuilder

 public function cloneInnerBuilder($property)
 {
     $mapping = $this->getFormMapping();
     Assert::isIndexExists($mapping, $property);
     $primitive = $mapping[$property];
     Assert::isInstance($primitive, 'PrimitiveForm');
     $result = new $this($primitive->getProto());
     if (isset($this->limitedPropertiesList[$primitive->getName()])) {
         $result->setLimitedPropertiesList($this->limitedPropertiesList[$primitive->getName()]);
     }
     return $result;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:PrototypedBuilder.class.php

示例15: getIdsArray

 public static function getIdsArray($objectsList)
 {
     $out = array();
     if (!$objectsList) {
         return $out;
     }
     Assert::isInstance(current($objectsList), 'Identifiable', 'only identifiable lists accepted');
     foreach ($objectsList as $object) {
         $out[] = $object->getId();
     }
     return $out;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:ArrayUtils.class.php


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