Skip to content

Commit

Permalink
Separate file/directory/exists assertions (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowhand authored Oct 16, 2024
1 parent 8164e8e commit 781144a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
));
}
Expand All @@ -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.',
Expand All @@ -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)
));
}
Expand Down

0 comments on commit 781144a

Please sign in to comment.