| @@ 1149-1159 (lines=11) @@ | ||
| 1146 | * |
|
| 1147 | * @throws InvalidArgumentException |
|
| 1148 | */ |
|
| 1149 | public static function unicodeLetters($value, $message = '') |
|
| 1150 | { |
|
| 1151 | static::string($value); |
|
| 1152 | ||
| 1153 | if (!\preg_match('/^\p{L}+$/u', $value)) { |
|
| 1154 | static::reportInvalidArgument(\sprintf( |
|
| 1155 | $message ?: 'Expected a value to contain only Unicode letters. Got: %s', |
|
| 1156 | static::valueToString($value) |
|
| 1157 | )); |
|
| 1158 | } |
|
| 1159 | } |
|
| 1160 | ||
| 1161 | /** |
|
| 1162 | * @param mixed $value |
|
| @@ 1018-1028 (lines=11) @@ | ||
| 1015 | * |
|
| 1016 | * @throws InvalidArgumentException |
|
| 1017 | */ |
|
| 1018 | public static function notWhitespaceOnly($value, $message = '') |
|
| 1019 | { |
|
| 1020 | static::string($value); |
|
| 1021 | ||
| 1022 | if (\preg_match('/^\s*$/', $value)) { |
|
| 1023 | static::reportInvalidArgument(\sprintf( |
|
| 1024 | $message ?: 'Expected a non-whitespace string. Got: %s', |
|
| 1025 | static::valueToString($value) |
|
| 1026 | )); |
|
| 1027 | } |
|
| 1028 | } |
|
| 1029 | ||
| 1030 | /** |
|
| 1031 | * @param string $value |
|
| @@ 1372-1382 (lines=11) @@ | ||
| 1369 | * |
|
| 1370 | * @throws InvalidArgumentException |
|
| 1371 | */ |
|
| 1372 | public static function fileExists($value, $message = '') |
|
| 1373 | { |
|
| 1374 | static::string($value); |
|
| 1375 | ||
| 1376 | if (!\file_exists($value)) { |
|
| 1377 | static::reportInvalidArgument(\sprintf( |
|
| 1378 | $message ?: 'The file %s does not exist.', |
|
| 1379 | static::valueToString($value) |
|
| 1380 | )); |
|
| 1381 | } |
|
| 1382 | } |
|
| 1383 | ||
| 1384 | /** |
|
| 1385 | * @param string $value |
|
| @@ 1426-1436 (lines=11) @@ | ||
| 1423 | * |
|
| 1424 | * @throws InvalidArgumentException |
|
| 1425 | */ |
|
| 1426 | public static function readable($value, $message = '') |
|
| 1427 | { |
|
| 1428 | static::string($value, $message); |
|
| 1429 | ||
| 1430 | if (!\is_readable($value)) { |
|
| 1431 | static::reportInvalidArgument(\sprintf( |
|
| 1432 | $message ?: 'The path %s is not readable.', |
|
| 1433 | static::valueToString($value) |
|
| 1434 | )); |
|
| 1435 | } |
|
| 1436 | } |
|
| 1437 | ||
| 1438 | /** |
|
| 1439 | * @param string $value |
|
| @@ 1444-1454 (lines=11) @@ | ||
| 1441 | * |
|
| 1442 | * @throws InvalidArgumentException |
|
| 1443 | */ |
|
| 1444 | public static function writable($value, $message = '') |
|
| 1445 | { |
|
| 1446 | static::string($value, $message); |
|
| 1447 | ||
| 1448 | if (!\is_writable($value)) { |
|
| 1449 | static::reportInvalidArgument(\sprintf( |
|
| 1450 | $message ?: 'The path %s is not writable.', |
|
| 1451 | static::valueToString($value) |
|
| 1452 | )); |
|
| 1453 | } |
|
| 1454 | } |
|
| 1455 | ||
| 1456 | /** |
|
| 1457 | * @psalm-assert class-string $value |
|
| @@ 1464-1474 (lines=11) @@ | ||
| 1461 | * |
|
| 1462 | * @throws InvalidArgumentException |
|
| 1463 | */ |
|
| 1464 | public static function classExists($value, $message = '') |
|
| 1465 | { |
|
| 1466 | static::string($value); |
|
| 1467 | ||
| 1468 | if (!\class_exists($value)) { |
|
| 1469 | static::reportInvalidArgument(\sprintf( |
|
| 1470 | $message ?: 'Expected an existing class name. Got: %s', |
|
| 1471 | static::valueToString($value) |
|
| 1472 | )); |
|
| 1473 | } |
|
| 1474 | } |
|
| 1475 | ||
| 1476 | /** |
|
| 1477 | * @param object|string $value |
|
| @@ 1503-1513 (lines=11) @@ | ||
| 1500 | * |
|
| 1501 | * @throws InvalidArgumentException |
|
| 1502 | */ |
|
| 1503 | public static function interfaceExists($value, $message = '') |
|
| 1504 | { |
|
| 1505 | static::string($value); |
|
| 1506 | ||
| 1507 | if (!\interface_exists($value)) { |
|
| 1508 | static::reportInvalidArgument(\sprintf( |
|
| 1509 | $message ?: 'Expected an existing interface name. got %s', |
|
| 1510 | static::valueToString($value) |
|
| 1511 | )); |
|
| 1512 | } |
|
| 1513 | } |
|
| 1514 | ||
| 1515 | /** |
|
| 1516 | * @param object|string $value |
|