| @@ 1262-1271 (lines=10) @@ | ||
| 1259 | * |
|
| 1260 | * @throws InvalidArgumentException |
|
| 1261 | */ |
|
| 1262 | public static function endsWith($value, $suffix, $message = '') |
|
| 1263 | { |
|
| 1264 | if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
| 1265 | static::reportInvalidArgument(\sprintf( |
|
| 1266 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
| 1267 | static::valueToString($value), |
|
| 1268 | static::valueToString($suffix) |
|
| 1269 | )); |
|
| 1270 | } |
|
| 1271 | } |
|
| 1272 | ||
| 1273 | /** |
|
| 1274 | * @psalm-pure |
|
| @@ 1282-1291 (lines=10) @@ | ||
| 1279 | * |
|
| 1280 | * @throws InvalidArgumentException |
|
| 1281 | */ |
|
| 1282 | public static function notEndsWith($value, $suffix, $message = '') |
|
| 1283 | { |
|
| 1284 | if ($suffix === \substr($value, -\strlen($suffix))) { |
|
| 1285 | static::reportInvalidArgument(\sprintf( |
|
| 1286 | $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
| 1287 | static::valueToString($value), |
|
| 1288 | static::valueToString($suffix) |
|
| 1289 | )); |
|
| 1290 | } |
|
| 1291 | } |
|
| 1292 | ||
| 1293 | /** |
|
| 1294 | * @psalm-pure |
|
| @@ 1717-1726 (lines=10) @@ | ||
| 1714 | * |
|
| 1715 | * @throws InvalidArgumentException |
|
| 1716 | */ |
|
| 1717 | public static function implementsInterface($value, $interface, $message = '') |
|
| 1718 | { |
|
| 1719 | if (!\in_array($interface, \class_implements($value))) { |
|
| 1720 | static::reportInvalidArgument(\sprintf( |
|
| 1721 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
| 1722 | static::valueToString($value), |
|
| 1723 | static::valueToString($interface) |
|
| 1724 | )); |
|
| 1725 | } |
|
| 1726 | } |
|
| 1727 | ||
| 1728 | /** |
|
| 1729 | * @psalm-pure |
|