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