Completed
Push — master ( 6aac25...fc5b3c )
by Sebastian
04:08 queued 01:04
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
 * Sftp file class.
6
 *
7
 * @package    phpbu
8
 * @subpackage Backup
9
 * @author     Sebastian Feldmann <[email protected]>
10
 * @author     Vitaly Baev <[email protected]>
11
 * @copyright  Sebastian Feldmann <[email protected]>
12
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
13
 * @link       http://phpbu.de/
14
 * @since      Class available since Release 5.1.0
15
 */
16
class Sftp extends Remote
17
{
18
    /**
19
     * @var \phpseclib\Net\SFTP
20
     */
21
    protected $sftp;
22
23
    /**
24
     * Sftp constructor.
25
     *
26
     * @param \phpseclib\Net\SFTP $sftp
27
     * @param array               $fileInfo
28
     * @param string              $remotePath
29
     */
30 2
    public function __construct(\phpseclib\Net\SFTP $sftp, array $fileInfo, string $remotePath)
31
    {
32 2
        $this->sftp         = $sftp;
33 2
        $this->filename     = $fileInfo['filename'];
34 2
        $this->pathname     = $remotePath . '/' . $fileInfo['filename'];
35 2
        $this->size         = $fileInfo['size'];
36 2
        $this->lastModified = $fileInfo['mtime'];
37 2
    }
38
39
    /**
40
     * Deletes the file.
41
     */
42 1
    public function unlink()
43
    {
44 1
        $this->sftp->delete($this->pathname);
45 1
    }
46
}
47