Assert\Assertion::directory PHP Method

directory() public static method

Assert that a directory exists
public static directory ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean
    public static function directory($value, $message = null, $propertyPath = null)
    {
        static::string($value, $message, $propertyPath);
        if (!is_dir($value)) {
            $message = sprintf($message ?: 'Path "%s" was expected to be a directory.', static::stringify($value));
            throw static::createException($value, $message, static::INVALID_DIRECTORY, $propertyPath);
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param string $filename
  */
 public function setFilename($filename)
 {
     Assertion::string($filename, 'Invalid filename.');
     Assertion::directory(dirname($filename), 'The selected directory does not exist.');
     Assertion::writeable(dirname($filename), 'The selected directory is not writable.');
     $this->filename = $filename;
 }
All Usage Examples Of Assert\Assertion::directory