public function __construct($directory, $extension = '', $umask = 02)
{
// YES, this needs to be *before* createPathIfNeeded()
if (!is_int($umask)) {
throw new \InvalidArgumentException(sprintf('The umask parameter is required to be integer, was: %s', gettype($umask)));
}
$this->umask = $umask;
if (!$this->createPathIfNeeded($directory)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $directory));
}
if (!is_writable($directory)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable.', $directory));
}
// YES, this needs to be *after* createPathIfNeeded()
$this->directory = realpath($directory);
$this->extension = (string) $extension;
$this->directoryStringLength = strlen($this->directory);
$this->extensionStringLength = strlen($this->extension);
$this->isRunningOnWindows = defined('PHP_WINDOWS_VERSION_BUILD');
}