Completed
Pull Request — master (#140)
by Vitaly
04:25
created

Sftp   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 31
ccs 10
cts 10
cp 1
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
     * @param string              $remotePath
22
     */
23 2
    public function __construct(\phpseclib\Net\SFTP $sftp, array $fileInfo, string $remotePath)
24
    {
25 2
        $this->sftp         = $sftp;
26 2
        $this->filename     = $fileInfo['filename'];
27 2
        $this->pathname     = $remotePath . '/' . $fileInfo['filename'];
28 2
        $this->size         = $fileInfo['size'];
29 2
        $this->lastModified = $fileInfo['mtime'];
30 2
    }
31
32
    /**
33
     * Deletes the file.
34
     */
35 1
    public function unlink()
36
    {
37 1
        $this->sftp->delete($this->pathname);
38
    }
39
}