| @@ 1037-1048 (lines=12) @@ | ||
| 1034 | * |
|
| 1035 | * @throws InvalidArgumentException |
|
| 1036 | */ |
|
| 1037 | public static function startsWith($value, $prefix, $message = '') |
|
| 1038 | { |
|
| 1039 | static::string($value); |
|
| 1040 | ||
| 1041 | if (0 !== \strpos($value, $prefix)) { |
|
| 1042 | static::reportInvalidArgument(\sprintf( |
|
| 1043 | $message ?: 'Expected a value to start with %2$s. Got: %s', |
|
| 1044 | static::valueToString($value), |
|
| 1045 | static::valueToString($prefix) |
|
| 1046 | )); |
|
| 1047 | } |
|
| 1048 | } |
|
| 1049 | ||
| 1050 | /** |
|
| 1051 | * @param mixed $value |
|
| @@ 1522-1531 (lines=10) @@ | ||
| 1519 | * |
|
| 1520 | * @throws InvalidArgumentException |
|
| 1521 | */ |
|
| 1522 | public static function implementsInterface($value, $interface, $message = '') |
|
| 1523 | { |
|
| 1524 | if (!\in_array($interface, \class_implements($value))) { |
|
| 1525 | static::reportInvalidArgument(\sprintf( |
|
| 1526 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
| 1527 | static::valueToString($value), |
|
| 1528 | static::valueToString($interface) |
|
| 1529 | )); |
|
| 1530 | } |
|
| 1531 | } |
|
| 1532 | ||
| 1533 | /** |
|
| 1534 | * @psalm-param class-string|object $classOrObject |
|