本文整理汇总了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";
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例6: getBitmask
public function getBitmask($config)
{
Assert::isInstance($config, 'AMQPExchangeConfig');
$bitmask = parent::getBitmask($config);
if ($config->getInternal()) {
$bitmask = $bitmask | AMQP_INTERNAL;
}
return $bitmask;
}
示例7: setValue
/**
* @return PrimitiveEnumList
**/
public function setValue($value)
{
if ($value) {
Assert::isArray($value);
Assert::isInstance(current($value), 'Enum');
}
$this->value = $value;
return $this;
}
示例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();
}
示例9: getBitmask
public function getBitmask($config)
{
Assert::isInstance($config, 'AMQPQueueConfig');
$bitmask = parent::getBitmask($config);
if ($config->getExclusive()) {
$bitmask = $bitmask | AMQP_EXCLUSIVE;
}
return $bitmask;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}