From 781144ab48cfe8982592113428983b8063a1bfb1 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 16 Oct 2024 09:18:00 -0500 Subject: [PATCH] Separate file/directory/exists assertions (#291) --- src/Assert.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Assert.php b/src/Assert.php index 70a29c4..a427420 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -1467,11 +1467,9 @@ public static function lengthBetween($value, $min, $max, $message = '') */ public static function fileExists($value, $message = '') { - static::string($value); - if (!\file_exists($value)) { static::reportInvalidArgument(\sprintf( - $message ?: 'The file %s does not exist.', + $message ?: 'The path %s does not exist.', static::valueToString($value) )); } @@ -1485,8 +1483,6 @@ public static function fileExists($value, $message = '') */ public static function file($value, $message = '') { - static::fileExists($value, $message); - if (!\is_file($value)) { static::reportInvalidArgument(\sprintf( $message ?: 'The path %s is not a file.', @@ -1503,11 +1499,9 @@ public static function file($value, $message = '') */ public static function directory($value, $message = '') { - static::fileExists($value, $message); - if (!\is_dir($value)) { static::reportInvalidArgument(\sprintf( - $message ?: 'The path %s is no directory.', + $message ?: 'The path %s is not a directory.', static::valueToString($value) )); }