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