1919use Cake \Datasource \ConnectionInterface ;
2020use Cake \Datasource \ConnectionManager ;
2121use InvalidArgumentException ;
22- use Symfony \Component \Filesystem \Filesystem ;
2322use Tools \Exceptionist ;
23+ use Tools \Filesystem ;
2424
2525/**
2626 * A trait that provides some methods used by all other classes
@@ -41,8 +41,9 @@ trait BackupTrait
4141 */
4242 public function getAbsolutePath (string $ path ): string
4343 {
44- if (!(new Filesystem ())->isAbsolutePath ($ path )) {
45- return add_slash_term (Configure::read ('DatabaseBackup.target ' )) . $ path ;
44+ $ Filesystem = new Filesystem ();
45+ if (!$ Filesystem ->isAbsolutePath ($ path )) {
46+ return $ Filesystem ->addSlashTerm (Configure::read ('DatabaseBackup.target ' )) . $ path ;
4647 }
4748
4849 return $ path ;
@@ -88,11 +89,7 @@ public function getDriver(?ConnectionInterface $connection = null): object
8889 $ connection = $ connection ?: $ this ->getConnection ();
8990 $ className = get_class_short_name ($ connection ->getDriver ());
9091 $ driver = App::classname (sprintf ('%s.%s ' , 'DatabaseBackup ' , $ className ), 'Driver ' );
91- Exceptionist::isTrue (
92- $ driver ,
93- __d ('database_backup ' , 'The `{0}` driver does not exist ' , $ className ),
94- InvalidArgumentException::class
95- );
92+ Exceptionist::isTrue ($ driver , __d ('database_backup ' , 'The `{0}` driver does not exist ' , $ className ), InvalidArgumentException::class);
9693
9794 return new $ driver ($ connection );
9895 }
@@ -106,7 +103,7 @@ public function getDriver(?ConnectionInterface $connection = null): object
106103 */
107104 public function getExtension (string $ filename ): ?string
108105 {
109- $ extension = get_extension ($ filename );
106+ $ extension = ( new Filesystem ())-> getExtension ($ filename );
110107
111108 return in_array ($ extension , array_keys (self ::$ validExtensions )) ? $ extension : null ;
112109 }
0 commit comments