@@ 1139-1148 (lines=10) @@ | ||
1136 | * |
|
1137 | * @throws InvalidArgumentException |
|
1138 | */ |
|
1139 | public static function endsWith($value, $suffix, $message = '') |
|
1140 | { |
|
1141 | if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
1142 | static::reportInvalidArgument(\sprintf( |
|
1143 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
1144 | static::valueToString($value), |
|
1145 | static::valueToString($suffix) |
|
1146 | )); |
|
1147 | } |
|
1148 | } |
|
1149 | ||
1150 | /** |
|
1151 | * @psalm-pure |
|
@@ 1159-1168 (lines=10) @@ | ||
1156 | * |
|
1157 | * @throws InvalidArgumentException |
|
1158 | */ |
|
1159 | public static function notEndsWith($value, $suffix, $message = '') |
|
1160 | { |
|
1161 | if ($suffix === \substr($value, -\strlen($suffix))) { |
|
1162 | static::reportInvalidArgument(\sprintf( |
|
1163 | $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
1164 | static::valueToString($value), |
|
1165 | static::valueToString($suffix) |
|
1166 | )); |
|
1167 | } |
|
1168 | } |
|
1169 | ||
1170 | /** |
|
1171 | * @psalm-pure |
|
@@ 1598-1607 (lines=10) @@ | ||
1595 | * |
|
1596 | * @throws InvalidArgumentException |
|
1597 | */ |
|
1598 | public static function implementsInterface($value, $interface, $message = '') |
|
1599 | { |
|
1600 | if (!\in_array($interface, \class_implements($value))) { |
|
1601 | static::reportInvalidArgument(\sprintf( |
|
1602 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
1603 | static::valueToString($value), |
|
1604 | static::valueToString($interface) |
|
1605 | )); |
|
1606 | } |
|
1607 | } |
|
1608 | ||
1609 | /** |
|
1610 | * @psalm-pure |