Server   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B upload() 0 24 3
A getRemoteName() 0 5 1
1
<?php namespace Nwidart\DbExporter;
2
3
use Config, SSH;
4
5
class Server
6
{
7
    protected $ignoredFiles = array('..', '.', '.gitkeep');
8
9
    public static $uploadedFiles;
10
11
    /**
12
     * What the class has to upload (migrations or seeds)
13
     * @var
14
     */
15
    protected $what;
16
17
    public function upload($what)
18
    {
19
        $localPath = "{$what}Path";
20
21
        $dir = scandir($localPath);
22
        $remotePath = config('db-exporter.remote.' . $what);
23
24
        foreach($dir as $file) {
25
            if (in_array($file, $this->ignoredFiles)) {
26
                continue;
27
            }
28
29
            // Capture the uploaded files for display later
30
            self::$uploadedFiles[$what][] = $remotePath . $file;
31
32
            // Copy the files
33
            SSH::into($this->getRemoteName())->put(
34
                $localPath .'/' . $file,
35
                $remotePath . $file
36
            );
37
        }
38
39
        return true;
40
    }
41
42
    private function getRemoteName()
43
    {
44
        // For now static from he config file.
45
        return config('db-exporter.remote.name');
46
    }
47
}