| @@ 1161-1170 (lines=10) @@ | ||
| 1158 | * |
|
| 1159 | * @throws InvalidArgumentException |
|
| 1160 | */ |
|
| 1161 | public static function endsWith($value, $suffix, $message = '') |
|
| 1162 | { |
|
| 1163 | if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
| 1164 | static::reportInvalidArgument(\sprintf( |
|
| 1165 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
| 1166 | static::valueToString($value), |
|
| 1167 | static::valueToString($suffix) |
|
| 1168 | )); |
|
| 1169 | } |
|
| 1170 | } |
|
| 1171 | ||
| 1172 | /** |
|
| 1173 | * @psalm-pure |
|
| @@ 1181-1190 (lines=10) @@ | ||
| 1178 | * |
|
| 1179 | * @throws InvalidArgumentException |
|
| 1180 | */ |
|
| 1181 | public static function notEndsWith($value, $suffix, $message = '') |
|
| 1182 | { |
|
| 1183 | if ($suffix === \substr($value, -\strlen($suffix))) { |
|
| 1184 | static::reportInvalidArgument(\sprintf( |
|
| 1185 | $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
| 1186 | static::valueToString($value), |
|
| 1187 | static::valueToString($suffix) |
|
| 1188 | )); |
|
| 1189 | } |
|
| 1190 | } |
|
| 1191 | ||
| 1192 | /** |
|
| 1193 | * @psalm-pure |
|
| @@ 1620-1629 (lines=10) @@ | ||
| 1617 | * |
|
| 1618 | * @throws InvalidArgumentException |
|
| 1619 | */ |
|
| 1620 | public static function implementsInterface($value, $interface, $message = '') |
|
| 1621 | { |
|
| 1622 | if (!\in_array($interface, \class_implements($value))) { |
|
| 1623 | static::reportInvalidArgument(\sprintf( |
|
| 1624 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
| 1625 | static::valueToString($value), |
|
| 1626 | static::valueToString($interface) |
|
| 1627 | )); |
|
| 1628 | } |
|
| 1629 | } |
|
| 1630 | ||
| 1631 | /** |
|
| 1632 | * @psalm-pure |
|