| @@ 638-649 (lines=12) @@ | ||
| 635 | * |
|
| 636 | * @throws InvalidArgumentException |
|
| 637 | */ |
|
| 638 | public static function isAOf($value, $class, $message = '') |
|
| 639 | { |
|
| 640 | static::string($class, 'Expected class as a string. Got: %s'); |
|
| 641 | ||
| 642 | if (!\is_a($value, $class, \is_string($value))) { |
|
| 643 | static::reportInvalidArgument(sprintf( |
|
| 644 | $message ?: 'Expected an instance of this class or to this class among his parents %2$s. Got: %s', |
|
| 645 | static::typeToString($value), |
|
| 646 | $class |
|
| 647 | )); |
|
| 648 | } |
|
| 649 | } |
|
| 650 | ||
| 651 | /** |
|
| 652 | * @psalm-pure |
|
| @@ 664-675 (lines=12) @@ | ||
| 661 | * |
|
| 662 | * @throws InvalidArgumentException |
|
| 663 | */ |
|
| 664 | public static function isNotA($value, $class, $message = '') |
|
| 665 | { |
|
| 666 | static::string($class, 'Expected class as a string. Got: %s'); |
|
| 667 | ||
| 668 | if (\is_a($value, $class, \is_string($value))) { |
|
| 669 | static::reportInvalidArgument(sprintf( |
|
| 670 | $message ?: 'Expected an instance of this class or to this class among his parents other than %2$s. Got: %s', |
|
| 671 | static::typeToString($value), |
|
| 672 | $class |
|
| 673 | )); |
|
| 674 | } |
|
| 675 | } |
|
| 676 | ||
| 677 | /** |
|
| 678 | * @psalm-pure |
|