Completed
Push — master ( b30e53...9fbf6c )
by Victor
01:55
created

File   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 71.43%

Importance

Changes 6
Bugs 1 Features 2
Metric Value
wmc 6
c 6
b 1
f 2
lcom 2
cbo 3
dl 0
loc 62
ccs 10
cts 14
cp 0.7143
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLocation() 0 4 1
A getRawContent() 0 4 1
A exists() 0 4 1
A isWritable() 0 4 1
A __toString() 0 4 1
1
<?php
2
/**
3
 * Created with PHP 5.6 generator
4
 * User: 
5
 * PHP 5.6 generator created by Victor MECH - April 2016
6
*/
7
8
namespace LazyEight\DiTesto\ValueObject;
9
10
11
class File
12
{
13
    /**
14
     * @var FileLocation
15
     */
16
    private $location;
17
    
18
    /**
19
     * @var FileContent
20
     */
21
    private $content;
22
23
    /**
24
     * @param FileLocation $location
25
     * @param FileContent $content
26
     */
27 1
    public function __construct(FileLocation $location, FileContent $content)
28
    {
29 1
        $this->location = $location;
30 1
        $this->content = $content;
31 1
    }
32
	
33
    /**
34
     * @return FileLocation The location of the file on disk
35
     */
36 1
    public function getLocation()
37
    {
38 1
        return clone $this->location;
39
    }
40
41
    /**
42
     * @return FileContent Raw content of the file
43
     */
44 1
    public function getRawContent()
45
    {
46 1
        return clone $this->content;
47
    }
48
49
    /**
50
     * @return bool
51
     */
52
    public function exists()
53
    {
54
        return file_exists($this->location->getValue());
55
    }
56
57
    /**
58
     * @return bool
59
     */
60
    public function isWritable()
61
    {
62
        return $this->location->isWritable();
63
    }
64
65
    /**
66
     * @return string
67
     */
68 1
    public function __toString()
69
    {
70 1
        return $this->getRawContent()->getValue()->getValue();
71
    }
72
}
73