@@ -32,7 +32,7 @@ public function __construct(Filesystem $filesystem = null)
32
32
}
33
33
34
34
/**
35
- * Get new file name if the given name is in use
35
+ * Gets new file name if the given name is in use
36
36
*
37
37
* @param string $destinationFile
38
38
* @return string
@@ -46,24 +46,23 @@ public function getNewFileName(string $destinationFile)
46
46
Filesystem \DriverPool::FILE
47
47
)->getDriver ();
48
48
49
+ if ($ driver ->isExists ($ destinationFile )) {
50
+ return $ this ->generateFileName ($ driver , $ fileInfo );
51
+ }
52
+
49
53
/**
50
54
* Try with non-local driver.
51
55
*/
52
- if (! $ driver-> isExists ( $ destinationFile )) {
53
- $ driver = $ this -> filesystem -> getDirectoryWrite (
54
- DirectoryList:: ROOT
55
- )-> getDriver ();
56
- }
56
+ $ driver = $ this -> filesystem -> getDirectoryWrite (DirectoryList:: ROOT )-> getDriver ();
57
+
58
+ return $ driver -> isExists ( $ destinationFile )
59
+ ? $ this -> generateFileName ( $ driver , $ fileInfo )
60
+ : $ fileInfo [ ' basename ' ];
57
61
58
- if ($ driver ->isExists ($ destinationFile )) {
59
- return $ this ->generateFileName ($ driver , $ fileInfo );
60
- } else {
61
- return $ fileInfo ['basename ' ];
62
- }
63
62
}
64
63
65
64
/**
66
- * Generates new file name until file with provided name doesn't exists
65
+ * Generates new file name until file with provided name doesn't exist
67
66
*
68
67
* @param DriverInterface $driver
69
68
* @param string $fileInfo
@@ -81,7 +80,7 @@ private function generateFileName($driver, $fileInfo, $index = 1)
81
80
}
82
81
83
82
/**
84
- * Get the path information from a given file
83
+ * Gets the path information from a given file
85
84
*
86
85
* @param string $destinationFile
87
86
* @return string|string[]
0 commit comments