SavedFile   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 64
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getContent() 0 3 1
A getType() 0 3 1
A getSize() 0 3 1
A getName() 0 3 1
A setContent() 0 3 1
A save() 0 3 1
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
}