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