| @@ 502-513 (lines=12) @@ | ||
| 499 | * |
|
| 500 | * @throws InvalidArgumentException |
|
| 501 | */ |
|
| 502 | public static function isAOf($value, $class, $message = '') |
|
| 503 | { |
|
| 504 | static::string($class, 'Expected class as a string. Got: %s'); |
|
| 505 | ||
| 506 | if (!\is_a($value, $class, \is_string($value))) { |
|
| 507 | static::reportInvalidArgument(sprintf( |
|
| 508 | $message ?: 'Expected an instance of this class or to this class among his parents %2$s. Got: %s', |
|
| 509 | static::typeToString($value), |
|
| 510 | $class |
|
| 511 | )); |
|
| 512 | } |
|
| 513 | } |
|
| 514 | ||
| 515 | /** |
|
| 516 | * @psalm-pure |
|
| @@ 528-539 (lines=12) @@ | ||
| 525 | * |
|
| 526 | * @throws InvalidArgumentException |
|
| 527 | */ |
|
| 528 | public static function isNotA($value, $class, $message = '') |
|
| 529 | { |
|
| 530 | static::string($class, 'Expected class as a string. Got: %s'); |
|
| 531 | ||
| 532 | if (\is_a($value, $class, \is_string($value))) { |
|
| 533 | static::reportInvalidArgument(sprintf( |
|
| 534 | $message ?: 'Expected an instance of this class or to this class among his parents other than %2$s. Got: %s', |
|
| 535 | static::typeToString($value), |
|
| 536 | $class |
|
| 537 | )); |
|
| 538 | } |
|
| 539 | } |
|
| 540 | ||
| 541 | /** |
|
| 542 | * @psalm-pure |
|