Completed
Pull Request — master (#140)
by
unknown
03:01
created
src/Backup/Collector/Local.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
             if ($file->getPathname() == $this->target->getPathname()) {
111 111
                 continue;
112 112
             }
113
-            if (preg_match('#' . $this->fileRegex . '#i', $file->getFilename())) {
114
-                $index               = date('YmdHis', $file->getMTime()) . '-' . $i . '-' . $file->getPathname();
113
+            if (preg_match('#'.$this->fileRegex.'#i', $file->getFilename())) {
114
+                $index               = date('YmdHis', $file->getMTime()).'-'.$i.'-'.$file->getPathname();
115 115
                 $this->files[$index] = new FileLocal($file->getFileInfo());
116 116
             }
117 117
         }
@@ -140,6 +140,6 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $dirTarget = Arr::getValue($this->target->getChangingPathElements(), $depth);
142 142
         $dirRegex  = Str::datePlaceholdersToRegex($dirTarget);
143
-        return preg_match('#' . $dirRegex . '#i', $dir);
143
+        return preg_match('#'.$dirRegex.'#i', $dir);
144 144
     }
145 145
 }
Please login to merge, or discard this patch.
src/Backup/Collector/OpenStack.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@
 block discarded – undo
52 52
                 continue;
53 53
             }
54 54
             // skip currently created backup
55
-            if ($object->name == $this->path . $this->target->getFilename()) {
55
+            if ($object->name == $this->path.$this->target->getFilename()) {
56 56
                 continue;
57 57
             }
58
-            if (preg_match('#' . $this->fileRegex . '#i', basename($object->name))) {
58
+            if (preg_match('#'.$this->fileRegex.'#i', basename($object->name))) {
59 59
                 $this->files[] = new \phpbu\App\Backup\File\OpenStack($this->container, $object);
60 60
             }
61 61
         }
Please login to merge, or discard this patch.
src/Backup/Sync/SoftLayer.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         // check for mandatory options
75 75
         foreach (['user', 'secret', 'container', 'host', 'path'] as $option) {
76 76
             if (!Arr::isSetAndNotEmptyString($config, $option)) {
77
-                throw new Exception('SoftLayer ' . $option . ' is mandatory');
77
+                throw new Exception('SoftLayer '.$option.' is mandatory');
78 78
             }
79 79
         }
80 80
 
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
     public function sync(Target $target, Result $result)
99 99
     {
100 100
         $sourcePath = $target->getPathname();
101
-        $targetPath = $this->path . $target->getFilename();
101
+        $targetPath = $this->path.$target->getFilename();
102 102
 
103 103
         $options       = ['adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 20];
104 104
         $objectStorage = new ObjectStorage($this->host, $this->user, $this->secret, $options);
105 105
 
106
-        $result->debug('softlayer source: ' . $sourcePath);
107
-        $result->debug('softlayer target: ' . $targetPath);
106
+        $result->debug('softlayer source: '.$sourcePath);
107
+        $result->debug('softlayer target: '.$targetPath);
108 108
 
109 109
         try {
110 110
             /** @var \ObjectStorage_Container $container */
111
-            $container = $objectStorage->with($this->container . $targetPath)
111
+            $container = $objectStorage->with($this->container.$targetPath)
112 112
                                        ->setLocalFile($sourcePath)
113
-                                       ->setMeta('description', 'PHPBU Backup: ' . date('r', time()))
113
+                                       ->setMeta('description', 'PHPBU Backup: '.date('r', time()))
114 114
                                        ->setHeader('Content-Type', $target->getMimeType());
115 115
             $container->create();
116 116
         } catch (\Exception $e) {
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
     public function simulate(Target $target, Result $result)
130 130
     {
131 131
         $result->debug(
132
-            'sync backup to SoftLayer' . PHP_EOL
133
-            . '  host:      ' . $this->host . PHP_EOL
134
-            . '  user:      ' . $this->user . PHP_EOL
135
-            . '  secret:     ********' . PHP_EOL
136
-            . '  container: ' . $this->container . PHP_EOL
137
-            . '  location:  ' . $this->path
132
+            'sync backup to SoftLayer'.PHP_EOL
133
+            . '  host:      '.$this->host.PHP_EOL
134
+            . '  user:      '.$this->user.PHP_EOL
135
+            . '  secret:     ********'.PHP_EOL
136
+            . '  container: '.$this->container.PHP_EOL
137
+            . '  location:  '.$this->path
138 138
         );
139 139
     }
140 140
 
Please login to merge, or discard this patch.
src/Backup/File/OpenStack.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         $this->container = $container;
24 24
         $this->filename = basename($object->name);
25 25
         $this->pathname = $object->name;
26
-        $this->size = (int)$object->contentLength;
26
+        $this->size = (int) $object->contentLength;
27 27
         $this->lastModified = $object->lastModified->getTimestamp();
28 28
     }
29 29
 
Please login to merge, or discard this patch.
src/Backup/Cleaner/Capacity.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         if ($this->deleteTarget) {
86 86
             $this->deleteTarget = false;
87 87
             $result->debug('target will be deleted as well');
88
-            $result->debug('delete ' . $target->getPathname());
88
+            $result->debug('delete '.$target->getPathname());
89 89
         }
90 90
         parent::simulate($target, $collector, $result);
91 91
     }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         // should the currently created backup be deleted as well?
140 140
         if ($this->deleteTarget) {
141 141
             $file = $target->toFile();
142
-            $index = date('YmdHis', $file->getMTime()) . '-' . count($files) . '-' . $file->getPathname();
142
+            $index = date('YmdHis', $file->getMTime()).'-'.count($files).'-'.$file->getPathname();
143 143
             $files[$index] = $file;
144 144
         }
145 145
         return $files;
Please login to merge, or discard this patch.
src/Backup/Collector/Sftp.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
             if ($fileInfo['filename'] == $this->target->getFilename()) {
52 52
                 continue;
53 53
             }
54
-            if (preg_match('#' . $this->fileRegex . '#i', $fileInfo['filename'])) {
54
+            if (preg_match('#'.$this->fileRegex.'#i', $fileInfo['filename'])) {
55 55
                 $this->files[] = new \phpbu\App\Backup\File\Sftp($this->sftp, $fileInfo, $this->path);
56 56
             }
57 57
         }
Please login to merge, or discard this patch.
src/Backup/File/Sftp.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     {
24 24
         $this->sftp         = $sftp;
25 25
         $this->filename     = $fileInfo['filename'];
26
-        $this->pathname     = $remotePath . '/' . $fileInfo['filename'];
26
+        $this->pathname     = $remotePath.'/'.$fileInfo['filename'];
27 27
         $this->size         = $fileInfo['size'];
28 28
         $this->lastModified = $fileInfo['mtime'];
29 29
     }
Please login to merge, or discard this patch.
src/Util/Str.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public static function withTrailingSlash($string)
212 212
     {
213
-        return $string . (self::hasTrailingSlash($string) ? '' : '/');
213
+        return $string.(self::hasTrailingSlash($string) ? '' : '/');
214 214
     }
215 215
 
216 216
     /**
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public static function hasLeadingSlash(string $string) : bool
234 234
     {
235
-        return substr($string, 0,1) === '/';
235
+        return substr($string, 0, 1) === '/';
236 236
     }
237 237
 
238 238
     /**
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     public static function withLeadingSlash($string)
245 245
     {
246
-        return (self::hasLeadingSlash($string) ? '' : '/') . $string;
246
+        return (self::hasLeadingSlash($string) ? '' : '/').$string;
247 247
     }
248 248
 
249 249
     /**
@@ -266,6 +266,6 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public static function appendPluralS($subject, $amount)
268 268
     {
269
-        return $subject . ($amount == 1 ? '' : (substr($subject, -1) == 's' ? '\'s' : 's'));
269
+        return $subject.($amount == 1 ? '' : (substr($subject, -1) == 's' ? '\'s' : 's'));
270 270
     }
271 271
 }
Please login to merge, or discard this patch.
src/Log/Mail.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
         $server                = gethostname();
164 164
         $this->sendOnlyOnError = Str::toBoolean(Arr::getValue($options, 'sendOnlyOnError'), false);
165 165
         $this->sendSimulating  = Str::toBoolean(Arr::getValue($options, 'sendOnSimulation'), true);
166
-        $this->subject         = Arr::getValue($options, 'subject', 'PHPBU backup report from ' . $server);
167
-        $this->senderMail      = Arr::getValue($options, 'sender.mail', 'phpbu@' . $server);
166
+        $this->subject         = Arr::getValue($options, 'subject', 'PHPBU backup report from '.$server);
167
+        $this->senderMail      = Arr::getValue($options, 'sender.mail', 'phpbu@'.$server);
168 168
         $this->senderName      = Arr::getValue($options, 'sender.name');
169 169
         $this->transportType   = Arr::getValue($options, 'transport', 'mail');
170 170
         $this->recipients      = array_map('trim', explode(';', $mails));
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function onPhpbuEnd(Event\App\End $event)
185 185
     {
186
-        $result  = $event->getResult();
186
+        $result = $event->getResult();
187 187
 
188 188
         if ($this->shouldMailBeSend($result)) {
189 189
             $header  = $this->getHeaderHtml();
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             $errors  = $this->getErrorHtml($result);
192 192
             $info    = $this->getInfoHtml($result);
193 193
             $footer  = $this->getFooterHtml();
194
-            $body    = '<html><body '. TPL::getSnippet('sBody') . '>'
194
+            $body    = '<html><body '.TPL::getSnippet('sBody').'>'
195 195
                      . $header
196 196
                      . $status
197 197
                      . $errors
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
             try {
205 205
                 /** @var \Swift_Message $message */
206 206
                 $message = new Swift_Message();
207
-                $message->setSubject($this->subject . ' [' . $state . ']')
207
+                $message->setSubject($this->subject.' ['.$state.']')
208 208
                         ->setFrom($this->senderMail, $this->senderName)
209 209
                         ->setTo($this->recipients)
210 210
                         ->setBody($body, 'text/html');
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
     {
359 359
         if (isset($options['sendmail.path'])) {
360 360
             $path    = $options['sendmail.path'];
361
-            $options = isset($options['sendmail.options']) ? ' ' . $options['sendmail.options'] : '';
361
+            $options = isset($options['sendmail.options']) ? ' '.$options['sendmail.options'] : '';
362 362
             /* @var $transport \Swift_SendmailTransport */
363
-            return new \Swift_SendmailTransport($path . $options);
363
+            return new \Swift_SendmailTransport($path.$options);
364 364
         }
365 365
         return new \Swift_SendmailTransport();
366 366
     }
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
      */
373 373
     protected function getHeaderHtml()
374 374
     {
375
-        return '<table ' . TPL::getSnippet('sTableContent') . '><tr><td ' . TPL::getSnippet('sTableContentCol') . '>' .
376
-               '<table ' . TPL::getSnippet('sTableHeader') . '><tr><td>PHPBU - backup report</td></tr></table>';
375
+        return '<table '.TPL::getSnippet('sTableContent').'><tr><td '.TPL::getSnippet('sTableContentCol').'>'.
376
+               '<table '.TPL::getSnippet('sTableHeader').'><tr><td>PHPBU - backup report</td></tr></table>';
377 377
     }
378 378
 
379 379
     /**
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
             $this->numCleanups,
411 411
             Str::appendPluralS('cleanup', $this->numCleanups)
412 412
         );
413
-        $html = '<table ' . sprintf(TPL::getSnippet('sTableStatus'), $color) .'>' .
414
-                 '<tr><td>' .
415
-                  '<span ' . TPL::getSnippet('sTableStatusText') . '>' . date('Y-m-d H:i') . '</span>' .
416
-                  '<h1 ' . TPL::getSnippet('sTableStatusHead') . '>' . $status . '</h1>' .
417
-                  '<span ' . TPL::getSnippet('sTableStatusText') . '>' . $info . '</span>' .
418
-                 '</td></tr>' .
413
+        $html = '<table '.sprintf(TPL::getSnippet('sTableStatus'), $color).'>'.
414
+                 '<tr><td>'.
415
+                  '<span '.TPL::getSnippet('sTableStatusText').'>'.date('Y-m-d H:i').'</span>'.
416
+                  '<h1 '.TPL::getSnippet('sTableStatusHead').'>'.$status.'</h1>'.
417
+                  '<span '.TPL::getSnippet('sTableStatusText').'>'.$info.'</span>'.
418
+                 '</td></tr>'.
419 419
                 '</table>';
420 420
 
421 421
         return $html;
@@ -432,17 +432,17 @@  discard block
 block discarded – undo
432 432
         $html   = '';
433 433
         $errors = $result->getErrors();
434 434
         if (count($errors)) {
435
-            $html .= '<table ' . TPL::getSnippet('sTableError') . '>';
435
+            $html .= '<table '.TPL::getSnippet('sTableError').'>';
436 436
             /* @var $e Exception */
437 437
             foreach ($errors as $e) {
438
-                $html .= '<tr><td ' . TPL::getSnippet('sTableErrorCol') . '>' .
438
+                $html .= '<tr><td '.TPL::getSnippet('sTableErrorCol').'>'.
439 439
                     sprintf(
440 440
                         "Exception '%s' with message '%s' in %s:%d",
441 441
                         get_class($e),
442 442
                         $e->getMessage(),
443 443
                         $e->getFile(),
444 444
                         $e->getLine()
445
-                    ) .
445
+                    ).
446 446
                     '</td></tr>';
447 447
 
448 448
             }
@@ -462,78 +462,78 @@  discard block
 block discarded – undo
462 462
         $html    = '';
463 463
         $backups = $result->getBackups();
464 464
         if (count($backups)) {
465
-            $html .= '<table ' . TPL::getSnippet('sTableBackup') . '>';
465
+            $html .= '<table '.TPL::getSnippet('sTableBackup').'>';
466 466
             /** @var \phpbu\App\Result\Backup $backup */
467 467
             foreach ($backups as $backup) {
468 468
                 if ($backup->allOk()) {
469 469
                     $color  = TPL::getSnippet('cStatusOK');
470 470
                     $status = 'OK';
471
-                } elseif($backup->okButSkipsOrFails()) {
471
+                } elseif ($backup->okButSkipsOrFails()) {
472 472
                     $color  = TPL::getSnippet('cStatusWARN');
473 473
                     $status = 'WARNING';
474 474
                 } else {
475 475
                     $color  = TPL::getSnippet('cStatusFAIL');
476 476
                     $status = 'FAILURE';
477 477
                 }
478
-                $html .= '<tr>' .
479
-                          '<td ' . sprintf(TPL::getSnippet('sTableBackupStatusColumn'), $color) . ' colspan="4">' .
480
-                          sprintf('backup <em>%s</em>', $backup->getName()) .
481
-                          ' <span ' . TPL::getSnippet('sTableBackupStatusText') . '>' . $status .'</span>'.
482
-                          '</td>' .
483
-                         '</tr>' .
484
-                         '<tr>' .
485
-                          '<td ' . TPL::getSnippet('sRowHead') . '>&nbsp;</td>' .
486
-                          '<td ' . TPL::getSnippet('sRowHead') . ' align="right">executed</td>' .
487
-                          '<td ' . TPL::getSnippet('sRowHead') . ' align="right">skipped</td>' .
488
-                          '<td ' . TPL::getSnippet('sRowHead') . ' align="right">failed</td>' .
478
+                $html .= '<tr>'.
479
+                          '<td '.sprintf(TPL::getSnippet('sTableBackupStatusColumn'), $color).' colspan="4">'.
480
+                          sprintf('backup <em>%s</em>', $backup->getName()).
481
+                          ' <span '.TPL::getSnippet('sTableBackupStatusText').'>'.$status.'</span>'.
482
+                          '</td>'.
483
+                         '</tr>'.
484
+                         '<tr>'.
485
+                          '<td '.TPL::getSnippet('sRowHead').'>&nbsp;</td>'.
486
+                          '<td '.TPL::getSnippet('sRowHead').' align="right">executed</td>'.
487
+                          '<td '.TPL::getSnippet('sRowHead').' align="right">skipped</td>'.
488
+                          '<td '.TPL::getSnippet('sRowHead').' align="right">failed</td>'.
489 489
                          '</tr>';
490 490
 
491
-                $html .= '<tr>' .
492
-                          '<td ' . TPL::getSnippet('sRowCheck') . '>checks</td>' .
493
-                          '<td ' . TPL::getSnippet('sRowCheck') . ' align="right">' .
494
-                            $backup->checkCount() . '
491
+                $html .= '<tr>'.
492
+                          '<td '.TPL::getSnippet('sRowCheck').'>checks</td>'.
493
+                          '<td '.TPL::getSnippet('sRowCheck').' align="right">'.
494
+                            $backup->checkCount().'
495 495
                            </td>' .
496
-                          '<td ' . TPL::getSnippet('sRowCheck') . ' align="right">
496
+                          '<td '.TPL::getSnippet('sRowCheck').' align="right">
497 497
                             &nbsp;
498 498
                            </td>' .
499
-                          '<td ' . TPL::getSnippet('sRowCheck') . ' align="right">' .
500
-                            $backup->checkCountFailed() .
501
-                          '</td>' .
502
-                         '</tr>' .
503
-                         '<tr>' .
504
-                          '<td ' . TPL::getSnippet('sRowCrypt') . '>crypts</td>' .
505
-                          '<td ' . TPL::getSnippet('sRowCrypt') . ' align="right">' .
506
-                            $backup->cryptCount() .
507
-                          '</td>' .
508
-                          '<td ' . TPL::getSnippet('sRowCrypt') . ' align="right">' .
509
-                            $backup->cryptCountSkipped() .
510
-                          '</td>' .
511
-                          '<td ' . TPL::getSnippet('sRowCrypt') . ' align="right">' .
512
-                            $backup->cryptCountFailed() .
513
-                          '</td>' .
514
-                         '</tr>' .
515
-                         '<tr>' .
516
-                          '<td ' . TPL::getSnippet('sRowSync') . '>syncs</td>' .
517
-                          '<td ' . TPL::getSnippet('sRowSync') . ' align="right">' .
518
-                            $backup->syncCount() . '</td>' .
519
-                          '<td ' . TPL::getSnippet('sRowSync') . ' align="right">' .
520
-                            $backup->syncCountSkipped() .
521
-                          '</td>' .
522
-                          '<td ' . TPL::getSnippet('sRowSync') . ' align="right">' .
523
-                            $backup->syncCountFailed() .
524
-                          '</td>' .
525
-                         '</tr>' .
526
-                         '<tr>' .
527
-                          '<td ' . TPL::getSnippet('sRowCleanup') . '>cleanups</td>' .
528
-                          '<td ' . TPL::getSnippet('sRowCleanup') . ' align="right">' .
529
-                            $backup->cleanupCount() .
530
-                          '</td>' .
531
-                          '<td ' . TPL::getSnippet('sRowCleanup') . ' align="right">' .
532
-                            $backup->cleanupCountSkipped() .
533
-                          '</td>' .
534
-                          '<td ' . TPL::getSnippet('sRowCleanup') . ' align="right">' .
535
-                            $backup->cleanupCountFailed() .
536
-                          '</td>' .
499
+                          '<td '.TPL::getSnippet('sRowCheck').' align="right">'.
500
+                            $backup->checkCountFailed().
501
+                          '</td>'.
502
+                         '</tr>'.
503
+                         '<tr>'.
504
+                          '<td '.TPL::getSnippet('sRowCrypt').'>crypts</td>'.
505
+                          '<td '.TPL::getSnippet('sRowCrypt').' align="right">'.
506
+                            $backup->cryptCount().
507
+                          '</td>'.
508
+                          '<td '.TPL::getSnippet('sRowCrypt').' align="right">'.
509
+                            $backup->cryptCountSkipped().
510
+                          '</td>'.
511
+                          '<td '.TPL::getSnippet('sRowCrypt').' align="right">'.
512
+                            $backup->cryptCountFailed().
513
+                          '</td>'.
514
+                         '</tr>'.
515
+                         '<tr>'.
516
+                          '<td '.TPL::getSnippet('sRowSync').'>syncs</td>'.
517
+                          '<td '.TPL::getSnippet('sRowSync').' align="right">'.
518
+                            $backup->syncCount().'</td>'.
519
+                          '<td '.TPL::getSnippet('sRowSync').' align="right">'.
520
+                            $backup->syncCountSkipped().
521
+                          '</td>'.
522
+                          '<td '.TPL::getSnippet('sRowSync').' align="right">'.
523
+                            $backup->syncCountFailed().
524
+                          '</td>'.
525
+                         '</tr>'.
526
+                         '<tr>'.
527
+                          '<td '.TPL::getSnippet('sRowCleanup').'>cleanups</td>'.
528
+                          '<td '.TPL::getSnippet('sRowCleanup').' align="right">'.
529
+                            $backup->cleanupCount().
530
+                          '</td>'.
531
+                          '<td '.TPL::getSnippet('sRowCleanup').' align="right">'.
532
+                            $backup->cleanupCountSkipped().
533
+                          '</td>'.
534
+                          '<td '.TPL::getSnippet('sRowCleanup').' align="right">'.
535
+                            $backup->cleanupCountFailed().
536
+                          '</td>'.
537 537
                          '</tr>';
538 538
 
539 539
             }
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      */
550 550
     protected function getFooterHtml()
551 551
     {
552
-        return '<p ' . TPL::getSnippet('sStats') . '>' . PHP_Timer::resourceUsage() . '</p>' .
552
+        return '<p '.TPL::getSnippet('sStats').'>'.PHP_Timer::resourceUsage().'</p>'.
553 553
                '</td></tr></table>';
554 554
     }
555 555
 }
Please login to merge, or discard this patch.