99use Codedge \Updater \Events \UpdateAvailable ;
1010use Codedge \Updater \Events \UpdateFailed ;
1111use Codedge \Updater \Events \UpdateSucceeded ;
12- use File ;
1312use GuzzleHttp \Client ;
13+ use Illuminate \Support \Facades \File ;
1414use Storage ;
1515use Symfony \Component \Finder \Finder ;
1616
@@ -56,7 +56,7 @@ public function __construct(Client $client, array $config)
5656 *
5757 * @return bool
5858 */
59- public function isNewVersionAvailable ($ currentVersion = '' ) : bool
59+ public function isNewVersionAvailable ($ currentVersion = '' ): bool
6060 {
6161 $ version = $ currentVersion ?: $ this ->getVersionInstalled ();
6262
@@ -124,7 +124,7 @@ public function fetch($version = '')
124124 *
125125 * @return bool
126126 */
127- public function update ($ version = '' ) : bool
127+ public function update ($ version = '' ): bool
128128 {
129129 $ this ->setPathToUpdate (base_path (), $ this ->config ['exclude_folders ' ]);
130130
@@ -138,15 +138,16 @@ public function update($version = '') : bool
138138 // Move all directories first
139139 collect ((new Finder ())->in ($ sourcePath )->exclude ($ this ->config ['exclude_folders ' ])->directories ()->sort (function ($ a , $ b ) {
140140 return strlen ($ b ->getRealpath ()) - strlen ($ a ->getRealpath ());
141- }))->each (function ($ directory ) { /** @var \SplFileInfo $directory */
142- if (count ( array_intersect (File:: directories (
143- $ directory ->getRealPath ()), $ this ->config ['exclude_folders ' ]) == 0 )
141+ }))->each (function (/** @var \SplFileInfo $directory */ $ directory ) {
142+ if (! $ this -> isDirectoryExcluded (
143+ File:: directories ( $ directory ->getRealPath ()), $ this ->config ['exclude_folders ' ])
144144 ) {
145145 File::copyDirectory (
146146 $ directory ->getRealPath (),
147147 base_path ($ directory ->getRelativePath ()).'/ ' .$ directory ->getBasename ()
148148 );
149149 }
150+
150151 File::deleteDirectory ($ directory ->getRealPath ());
151152 });
152153
@@ -178,7 +179,7 @@ public function update($version = '') : bool
178179 *
179180 * @return string
180181 */
181- public function getVersionInstalled ($ prepend = '' , $ append = '' ) : string
182+ public function getVersionInstalled ($ prepend = '' , $ append = '' ): string
182183 {
183184 return $ prepend .$ this ->config ['version_installed ' ].$ append ;
184185 }
@@ -192,7 +193,7 @@ public function getVersionInstalled($prepend = '', $append = '') : string
192193 *
193194 * @return string
194195 */
195- public function getVersionAvailable ($ prepend = '' , $ append = '' ) : string
196+ public function getVersionAvailable ($ prepend = '' , $ append = '' ): string
196197 {
197198 if ($ this ->versionFileExists ()) {
198199 $ version = $ prepend .$ this ->getVersionFile ().$ append ;
@@ -240,7 +241,7 @@ protected function getRepositoryReleases()
240241 *
241242 * @return bool
242243 */
243- protected function versionFileExists () : bool
244+ protected function versionFileExists (): bool
244245 {
245246 return Storage::exists (static ::NEW_VERSION_FILE );
246247 }
@@ -252,7 +253,7 @@ protected function versionFileExists() : bool
252253 *
253254 * @return bool
254255 */
255- protected function setVersionFile (string $ content ) : bool
256+ protected function setVersionFile (string $ content ): bool
256257 {
257258 return Storage::put (static ::NEW_VERSION_FILE , $ content );
258259 }
@@ -262,7 +263,7 @@ protected function setVersionFile(string $content) : bool
262263 *
263264 * @return string
264265 */
265- protected function getVersionFile () : string
266+ protected function getVersionFile (): string
266267 {
267268 return Storage::get (static ::NEW_VERSION_FILE );
268269 }
@@ -272,7 +273,7 @@ protected function getVersionFile() : string
272273 *
273274 * @return bool
274275 */
275- protected function deleteVersionFile () : bool
276+ protected function deleteVersionFile (): bool
276277 {
277278 return Storage::delete (static ::NEW_VERSION_FILE );
278279 }
0 commit comments