Completed
Push — master ( 6e7b55...86094f )
by Sebastian
03:17
created

Dropbox   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 36
ccs 12
cts 12
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 8 2
1
<?php
2
namespace phpbu\App\Backup\File;
3
4
use Kunnu\Dropbox\Dropbox as DropboxApi;
5
use Kunnu\Dropbox\Models\FileMetadata;
6
7
/**
8
 * Dropbox class.
9
 *
10
 * @package    phpbu
11
 * @subpackage Backup
12
 * @author     Sebastian Feldmann <[email protected]>
13
 * @author     Vitaly Baev <[email protected]>
14
 * @copyright  Sebastian Feldmann <[email protected]>
15
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
16
 * @link       http://phpbu.de/
17
 * @since      Class available since Release 5.1.0
18
 */
19
class Dropbox extends Remote
20
{
21
    /**
22
     * @var DropboxApi
23
     */
24
    protected $client;
25
26
    /**
27
     * Dropbox constructor.
28
     *
29
     * @param DropboxApi   $client
30
     * @param FileMetadata $dropboxFile
31
     */
32 3
    public function __construct(DropboxApi $client, FileMetadata $dropboxFile)
33
    {
34 3
        $this->client       = $client;
35 3
        $this->filename     = $dropboxFile->getName();
36 3
        $this->pathname     = $dropboxFile->getPathDisplay();
37 3
        $this->size         = $dropboxFile->getSize();
38 3
        $this->lastModified = strtotime($dropboxFile->getClientModified());
39 3
    }
40
41
    /**
42
     * Deletes the file.
43
     *
44
     * @throws \phpbu\App\Exception
45
     */
46 2
    public function unlink()
47
    {
48
        try {
49 2
            $this->client->delete($this->pathname);
50 1
        } catch (\Exception $e) {
51 1
            throw new \phpbu\App\Exception($e->getMessage());
52
        }
53 1
    }
54
}
55