SavedFile::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
namespace rtens\domin\parameters\file;
3
4
use rtens\domin\parameters\File;
5
6
class SavedFile implements File {
7
8
    /** @var string */
9
    private $path;
10
11
    /** @var string */
12
    private $type;
13
14
    /** @var string */
15
    private $name;
16
17
    /**
18
     * @param string $path
19
     * @param string $name
20
     * @param string $type
21
     */
22
    public function __construct($path, $name, $type) {
23
        $this->path = $path;
24
        $this->name = $name;
25
        $this->type = $type;
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function getContent() {
32
        return file_get_contents($this->path);
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getType() {
39
        return $this->type;
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function getSize() {
46
        return filesize($this->path);
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getName() {
53
        return $this->name;
54
    }
55
56
    /**
57
     * @param string $content
58
     */
59
    public function setContent($content) {
60
        file_put_contents($this->path, $content);
61
    }
62
63
    /**
64
     * @param string $path
65
     */
66
    public function save($path) {
67
        copy($this->path, $path);
68
    }
69
}