| @@ 1323-1332 (lines=10) @@ | ||
| 1320 | * |
|
| 1321 | * @throws InvalidArgumentException |
|
| 1322 | */ |
|
| 1323 | public static function endsWith($value, $suffix, $message = '') |
|
| 1324 | { |
|
| 1325 | if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
| 1326 | static::reportInvalidArgument(\sprintf( |
|
| 1327 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
| 1328 | static::valueToString($value), |
|
| 1329 | static::valueToString($suffix) |
|
| 1330 | )); |
|
| 1331 | } |
|
| 1332 | } |
|
| 1333 | ||
| 1334 | /** |
|
| 1335 | * @psalm-pure |
|
| @@ 1343-1352 (lines=10) @@ | ||
| 1340 | * |
|
| 1341 | * @throws InvalidArgumentException |
|
| 1342 | */ |
|
| 1343 | public static function notEndsWith($value, $suffix, $message = '') |
|
| 1344 | { |
|
| 1345 | if ($suffix === \substr($value, -\strlen($suffix))) { |
|
| 1346 | static::reportInvalidArgument(\sprintf( |
|
| 1347 | $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
| 1348 | static::valueToString($value), |
|
| 1349 | static::valueToString($suffix) |
|
| 1350 | )); |
|
| 1351 | } |
|
| 1352 | } |
|
| 1353 | ||
| 1354 | /** |
|
| 1355 | * @psalm-pure |
|
| @@ 1780-1789 (lines=10) @@ | ||
| 1777 | * |
|
| 1778 | * @throws InvalidArgumentException |
|
| 1779 | */ |
|
| 1780 | public static function implementsInterface($value, $interface, $message = '') |
|
| 1781 | { |
|
| 1782 | if (!\in_array($interface, \class_implements($value))) { |
|
| 1783 | static::reportInvalidArgument(\sprintf( |
|
| 1784 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
| 1785 | static::valueToString($value), |
|
| 1786 | static::valueToString($interface) |
|
| 1787 | )); |
|
| 1788 | } |
|
| 1789 | } |
|
| 1790 | ||
| 1791 | /** |
|
| 1792 | * @psalm-pure |
|