@@ 1119-1128 (lines=10) @@ | ||
1116 | * |
|
1117 | * @throws InvalidArgumentException |
|
1118 | */ |
|
1119 | public static function endsWith($value, $suffix, $message = '') |
|
1120 | { |
|
1121 | if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
1122 | static::reportInvalidArgument(\sprintf( |
|
1123 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
1124 | static::valueToString($value), |
|
1125 | static::valueToString($suffix) |
|
1126 | )); |
|
1127 | } |
|
1128 | } |
|
1129 | ||
1130 | /** |
|
1131 | * @psalm-pure |
|
@@ 1139-1148 (lines=10) @@ | ||
1136 | * |
|
1137 | * @throws InvalidArgumentException |
|
1138 | */ |
|
1139 | public static function notEndsWith($value, $suffix, $message = '') |
|
1140 | { |
|
1141 | if ($suffix === \substr($value, -\strlen($suffix))) { |
|
1142 | static::reportInvalidArgument(\sprintf( |
|
1143 | $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
1144 | static::valueToString($value), |
|
1145 | static::valueToString($suffix) |
|
1146 | )); |
|
1147 | } |
|
1148 | } |
|
1149 | ||
1150 | /** |
|
1151 | * @psalm-pure |
|
@@ 1578-1587 (lines=10) @@ | ||
1575 | * |
|
1576 | * @throws InvalidArgumentException |
|
1577 | */ |
|
1578 | public static function implementsInterface($value, $interface, $message = '') |
|
1579 | { |
|
1580 | if (!\in_array($interface, \class_implements($value))) { |
|
1581 | static::reportInvalidArgument(\sprintf( |
|
1582 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
1583 | static::valueToString($value), |
|
1584 | static::valueToString($interface) |
|
1585 | )); |
|
1586 | } |
|
1587 | } |
|
1588 | ||
1589 | /** |
|
1590 | * @psalm-pure |