@@ 1740-1749 (lines=10) @@ | ||
1737 | * |
|
1738 | * @throws InvalidArgumentException |
|
1739 | */ |
|
1740 | public static function implementsInterface($value, $interface, $message = '') |
|
1741 | { |
|
1742 | if (!\in_array($interface, \class_implements($value))) { |
|
1743 | static::reportInvalidArgument(\sprintf( |
|
1744 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
1745 | static::valueToString($value), |
|
1746 | static::valueToString($interface) |
|
1747 | )); |
|
1748 | } |
|
1749 | } |
|
1750 | ||
1751 | /** |
|
1752 | * @psalm-pure |
|
@@ 1283-1292 (lines=10) @@ | ||
1280 | * |
|
1281 | * @throws InvalidArgumentException |
|
1282 | */ |
|
1283 | public static function endsWith($value, $suffix, $message = '') |
|
1284 | { |
|
1285 | if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
1286 | static::reportInvalidArgument(\sprintf( |
|
1287 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
1288 | static::valueToString($value), |
|
1289 | static::valueToString($suffix) |
|
1290 | )); |
|
1291 | } |
|
1292 | } |
|
1293 | ||
1294 | /** |
|
1295 | * @psalm-pure |
|
@@ 1303-1312 (lines=10) @@ | ||
1300 | * |
|
1301 | * @throws InvalidArgumentException |
|
1302 | */ |
|
1303 | public static function notEndsWith($value, $suffix, $message = '') |
|
1304 | { |
|
1305 | if ($suffix === \substr($value, -\strlen($suffix))) { |
|
1306 | static::reportInvalidArgument(\sprintf( |
|
1307 | $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
1308 | static::valueToString($value), |
|
1309 | static::valueToString($suffix) |
|
1310 | )); |
|
1311 | } |
|
1312 | } |
|
1313 | ||
1314 | /** |
|
1315 | * @psalm-pure |