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