Server::getRemoteName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
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
}