| @@ 483-494 (lines=12) @@ | ||
| 480 | * |
|
| 481 | * @throws InvalidArgumentException |
|
| 482 | */ |
|
| 483 | public static function isAOf($value, $class, $message = '') |
|
| 484 | { |
|
| 485 | static::string($class, 'Expected class as a string. Got: %s'); |
|
| 486 | ||
| 487 | if (!\is_a($value, $class, \is_string($value))) { |
|
| 488 | static::reportInvalidArgument(sprintf( |
|
| 489 | $message ?: 'Expected an instance of this class or to this class among his parents %2$s. Got: %s', |
|
| 490 | static::typeToString($value), |
|
| 491 | $class |
|
| 492 | )); |
|
| 493 | } |
|
| 494 | } |
|
| 495 | ||
| 496 | /** |
|
| 497 | * @psalm-pure |
|
| @@ 509-520 (lines=12) @@ | ||
| 506 | * |
|
| 507 | * @throws InvalidArgumentException |
|
| 508 | */ |
|
| 509 | public static function isNotA($value, $class, $message = '') |
|
| 510 | { |
|
| 511 | static::string($class, 'Expected class as a string. Got: %s'); |
|
| 512 | ||
| 513 | if (\is_a($value, $class, \is_string($value))) { |
|
| 514 | static::reportInvalidArgument(sprintf( |
|
| 515 | $message ?: 'Expected an instance of this class or to this class among his parents other than %2$s. Got: %s', |
|
| 516 | static::typeToString($value), |
|
| 517 | $class |
|
| 518 | )); |
|
| 519 | } |
|
| 520 | } |
|
| 521 | ||
| 522 | /** |
|
| 523 | * @psalm-pure |
|