@@ 1101-1110 (lines=10) @@ | ||
1098 | * |
|
1099 | * @throws InvalidArgumentException |
|
1100 | */ |
|
1101 | public static function endsWith($value, $suffix, $message = '') |
|
1102 | { |
|
1103 | if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
1104 | static::reportInvalidArgument(\sprintf( |
|
1105 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
1106 | static::valueToString($value), |
|
1107 | static::valueToString($suffix) |
|
1108 | )); |
|
1109 | } |
|
1110 | } |
|
1111 | ||
1112 | /** |
|
1113 | * @psalm-pure |
|
@@ 1121-1130 (lines=10) @@ | ||
1118 | * |
|
1119 | * @throws InvalidArgumentException |
|
1120 | */ |
|
1121 | public static function notEndsWith($value, $suffix, $message = '') |
|
1122 | { |
|
1123 | if ($suffix === \substr($value, -\strlen($suffix))) { |
|
1124 | static::reportInvalidArgument(\sprintf( |
|
1125 | $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
1126 | static::valueToString($value), |
|
1127 | static::valueToString($suffix) |
|
1128 | )); |
|
1129 | } |
|
1130 | } |
|
1131 | ||
1132 | /** |
|
1133 | * @psalm-pure |
|
@@ 1560-1569 (lines=10) @@ | ||
1557 | * |
|
1558 | * @throws InvalidArgumentException |
|
1559 | */ |
|
1560 | public static function implementsInterface($value, $interface, $message = '') |
|
1561 | { |
|
1562 | if (!\in_array($interface, \class_implements($value))) { |
|
1563 | static::reportInvalidArgument(\sprintf( |
|
1564 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
1565 | static::valueToString($value), |
|
1566 | static::valueToString($interface) |
|
1567 | )); |
|
1568 | } |
|
1569 | } |
|
1570 | ||
1571 | /** |
|
1572 | * @psalm-pure |