@@ 646-657 (lines=12) @@ | ||
643 | * |
|
644 | * @throws InvalidArgumentException |
|
645 | */ |
|
646 | public static function isAOf($value, $class, $message = '') |
|
647 | { |
|
648 | static::string($class, 'Expected class as a string. Got: %s'); |
|
649 | ||
650 | if (!\is_a($value, $class, \is_string($value))) { |
|
651 | static::reportInvalidArgument(sprintf( |
|
652 | $message ?: 'Expected an instance of this class or to this class among his parents %2$s. Got: %s', |
|
653 | static::typeToString($value), |
|
654 | $class |
|
655 | )); |
|
656 | } |
|
657 | } |
|
658 | ||
659 | /** |
|
660 | * @psalm-pure |
|
@@ 672-683 (lines=12) @@ | ||
669 | * |
|
670 | * @throws InvalidArgumentException |
|
671 | */ |
|
672 | public static function isNotA($value, $class, $message = '') |
|
673 | { |
|
674 | static::string($class, 'Expected class as a string. Got: %s'); |
|
675 | ||
676 | if (\is_a($value, $class, \is_string($value))) { |
|
677 | static::reportInvalidArgument(sprintf( |
|
678 | $message ?: 'Expected an instance of this class or to this class among his parents other than %2$s. Got: %s', |
|
679 | static::typeToString($value), |
|
680 | $class |
|
681 | )); |
|
682 | } |
|
683 | } |
|
684 | ||
685 | /** |
|
686 | * @psalm-pure |