Completed
Pull Request — master (#140)
by
unknown
11:59 queued 08:36
created

Ftp::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
crap 2
1
<?php
2
namespace phpbu\App\Backup\File;
3
4
use League\Flysystem\FileNotFoundException;
5
use League\Flysystem\Filesystem;
6
7
class Ftp extends Remote
8
{
9
    /**
10
     * @var Filesystem
11
     */
12
    private $flySystem;
13
14
    /**
15
     * Ftp constructor.
16
     *
17
     * @param Filesystem $flySystem
18
     * @param array      $metadata
19
     */
20
    public function __construct(Filesystem $flySystem, array $metadata)
21
    {
22
        $this->flySystem = $flySystem;
23
        $this->filename     = $metadata['basename'];
24
        $this->size         = $metadata['size'];
25
        $this->pathname     = $metadata['path'];
26
        $this->lastModified = $this->flySystem->getTimestamp($this->pathname);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->flySystem->getTimestamp($this->pathname) of type string or false is incompatible with the declared type integer of property $lastModified.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
27
    }
28
29
    /**
30
     * Deletes the file.
31
     *
32
     * @throws \phpbu\App\Exception
33
     */
34
    public function unlink()
35
    {
36
        try {
37
            $this->flySystem->delete($this->pathname);
38
        } catch (FileNotFoundException $e) {
39
            throw new \phpbu\App\Exception($e->getMessage());
40
        }
41
    }
42
}