Completed
Pull Request — master (#140)
by
unknown
03:55
created

Sftp   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 32
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A unlink() 0 4 1
1
<?php
2
namespace phpbu\App\Backup\File;
3
4
/**
5
 * File Sftp class
6
 *
7
 * @package phpbu\App\Backup\File
8
 */
9
class Sftp extends Remote
10
{
11
    /**
12
     * @var \phpseclib\Net\SFTP
13
     */
14
    protected $sftp;
15
16
    /**
17
     * Sftp constructor.
18
     *
19
     * @param \phpseclib\Net\SFTP $sftp
20
     * @param array               $fileInfo
21
     */
22
    public function __construct(\phpseclib\Net\SFTP $sftp, array $fileInfo, string $remotePath)
23
    {
24
        $this->sftp         = $sftp;
25
        $this->filename     = $fileInfo['filename'];
26
        $this->pathname     = $remotePath . '/' . $fileInfo['filename'];
27
        $this->size         = $fileInfo['size'];
28
        $this->lastModified = $fileInfo['mtime'];
29
    }
30
31
    /**
32
     * Deletes the file.
33
     *
34
     * @throws \phpbu\App\Exception
35
     */
36
    public function unlink()
37
    {
38
        $this->sftp->delete($this->pathname);
39
    }
40
}