11<?php
2+
23namespace CodexShaper \DBM \Commands ;
34
45use CodexShaper \DBM \Facades \Driver ;
@@ -43,23 +44,24 @@ protected function getOptions()
4344 */
4445 protected function findComposer ()
4546 {
46- if (file_exists (getcwd () . '/composer.phar ' )) {
47- return '" ' . PHP_BINARY . '" ' . getcwd () . '/composer.phar ' ;
47+ if (file_exists (getcwd (). '/composer.phar ' )) {
48+ return '" ' . PHP_BINARY . '" ' . getcwd (). '/composer.phar ' ;
4849 }
50+
4951 return 'composer ' ;
5052 }
5153
5254 public function getFileName ($ table , $ database )
5355 {
5456 $ prefix = (strlen ($ table ) > 0 )
55- ? 'table_ ' . strtolower (str_replace ('- ' , '_ ' , $ table )) . '_ '
56- : 'database_ ' . strtolower (str_replace ('- ' , '_ ' , $ database )) . '_ ' ;
57+ ? 'table_ ' . strtolower (str_replace ('- ' , '_ ' , $ table )). '_ '
58+ : 'database_ ' . strtolower (str_replace ('- ' , '_ ' , $ database )). '_ ' ;
5759
5860 $ extension = Driver::isMongoDB () ? '' : '.sql ' ;
59- $ fileName = $ prefix . 'backup_ ' . date ('G_a_m_d_y_h_i_s ' ) . $ extension ;
61+ $ fileName = $ prefix. 'backup_ ' . date ('G_a_m_d_y_h_i_s ' ). $ extension ;
6062
6163 if (Driver::isSqlite ()) {
62- $ fileName = 'backup_ ' . date ('G_a_m_d_y_h_i_s ' ) . $ extension ;
64+ $ fileName = 'backup_ ' . date ('G_a_m_d_y_h_i_s ' ). $ extension ;
6365 }
6466
6567 return $ fileName ;
@@ -72,18 +74,18 @@ public function backup(Dumper $dumper, array $data)
7274 $ compressBinaryPath = config ('dbm.backup.compress_binary_path ' , '' );
7375 $ compressCommand = config ('dbm.backup.compress_command ' , 'gzip ' );
7476 $ compressExtension = config ('dbm.backup.compress_extension ' , '.gz ' );
75- $ dumpBinaryPath = config ('dbm.backup. ' . $ data ['driver ' ] . '.binary_path ' , '' );
77+ $ dumpBinaryPath = config ('dbm.backup. ' . $ data ['driver ' ]. '.binary_path ' , '' );
7678
7779 switch ($ data ['driver ' ]) {
7880 case 'mysql ' :
7981 case 'pgsql ' :
80- if (!empty ($ data ['table ' ])) {
82+ if (! empty ($ data ['table ' ])) {
8183 $ dumper ->setTables ($ data ['table ' ]);
8284 }
8385 break ;
8486 case 'mongodb ' :
8587 $ dsn = config ('dbm.backup.mongodb.dsn ' , '' );
86- if (!empty ($ dsn ) && method_exists ($ dumper , 'setUri ' )) {
88+ if (! empty ($ dsn ) && method_exists ($ dumper , 'setUri ' )) {
8789 $ dumper ->setUri ($ dsn );
8890 }
8991 break ;
@@ -115,17 +117,17 @@ public function handle(Filesystem $filesystem, Dumper $dumper)
115117 $ this ->info ('Start Database Backup ' );
116118
117119 $ driver = dbm_driver ();
118- $ database = config ('database.connections. ' . $ driver . '.database ' , 'dbm ' );
120+ $ database = config ('database.connections. ' . $ driver. '.database ' , 'dbm ' );
119121 $ table = ($ this ->option ('table ' ) != null ) ? $ this ->option ('table ' ) : '' ;
120122
121123 try {
122124 $ directory = (config ('dbm.backup.dir ' , 'backups ' ) != '' )
123- ? DIRECTORY_SEPARATOR . config ('dbm.backup.dir ' , 'backups ' )
125+ ? DIRECTORY_SEPARATOR . config ('dbm.backup.dir ' , 'backups ' )
124126 : '' ;
125- $ directoryPath = storage_path ('app ' ) . $ directory . DIRECTORY_SEPARATOR . $ driver ;
126- $ filePath = $ directoryPath . DIRECTORY_SEPARATOR . $ this ->getFileName ($ table , $ database );
127+ $ directoryPath = storage_path ('app ' ). $ directory. DIRECTORY_SEPARATOR . $ driver ;
128+ $ filePath = $ directoryPath. DIRECTORY_SEPARATOR . $ this ->getFileName ($ table , $ database );
127129
128- if (!File::isDirectory ($ directoryPath )) {
130+ if (! File::isDirectory ($ directoryPath )) {
129131 File::makeDirectory ($ directoryPath , 0777 , true , true );
130132 }
131133
@@ -138,8 +140,6 @@ public function handle(Filesystem $filesystem, Dumper $dumper)
138140 $ this ->info ('Backup completed ' );
139141 } catch (\Exception $ e ) {
140142 throw new \Exception ($ e ->getMessage (), 1 );
141-
142143 }
143-
144144 }
145145}
0 commit comments