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

Dropbox   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 36
ccs 0
cts 16
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 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
class Dropbox extends Remote
9
{
10
    /**
11
     * @var DropboxApi
12
     */
13
    protected $client;
14
15
    /**
16
     * Dropbox constructor.
17
     *
18
     * @param DropboxApi   $client
19
     * @param FileMetadata $dropboxFile
20
     */
21
    public function __construct(DropboxApi $client, FileMetadata $dropboxFile)
22
    {
23
        $this->client = $client;
24
        $this->filename = $dropboxFile->getName();
25
        $this->pathname = $dropboxFile->getPathDisplay();
26
        $this->size = $dropboxFile->getSize();
27
        $this->lastModified = strtotime($dropboxFile->getClientModified());
28
    }
29
30
    /**
31
     * Deletes the file.
32
     *
33
     * @throws \phpbu\App\Exception
34
     */
35
    public function unlink()
36
    {
37
        try {
38
            $this->client->delete($this->pathname);
39
        } catch (DropboxClientException $e) {
40
            throw new \phpbu\App\Exception($e->getMessage());
41
        }
42
    }
43
}
44