Webmozart\Assert\Assert::implementsInterface PHP Method

implementsInterface() public static method

public static implementsInterface ( $value, $interface, $message = '' )
    public static function implementsInterface($value, $interface, $message = '')
    {
        if (!in_array($interface, class_implements($value))) {
            static::reportInvalidArgument(sprintf($message ?: 'Expected an implementation of %2$s. Got: %s', static::valueToString($value), static::valueToString($interface)));
        }
    }

Usage Example

示例#1
0
 /**
  * @param PromotionSubjectInterface $subject
  *
  * @return bool
  */
 protected function isSubjectValid(PromotionSubjectInterface $subject)
 {
     Assert::implementsInterface($subject, OrderInterface::class);
     return 0 !== $subject->countItems();
 }
All Usage Examples Of Webmozart\Assert\Assert::implementsInterface