Completed
Push — master ( 6aac25...fc5b3c )
by Sebastian
04:08 queued 01:04
created

Dropbox   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 83.33%

Importance

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