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