Completed
Pull Request — develop (#89)
by Jaap
02:41
created

LocalFile   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 47
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getContents() 0 4 1
A md5() 0 4 1
A path() 0 4 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Reflection\File;
14
15
16
use phpDocumentor\Reflection\File;
17
18
/**
19
 * Represents a local file on the file system.
20
 */
21
final class LocalFile implements File
22
{
23
    /**
24
     * Path to the file.
25
     * @var string
26
     */
27
    private $path;
28
29
    /**
30
     * LocalFile constructor.
31
     * @param string $path
32
     */
33 3
    public function __construct($path)
34
    {
35 3
        $this->path = $path;
36 3
    }
37
38
    /**
39
     * Returns the content of the file as a string.
40
     *
41
     * @return string
42
     */
43 1
    public function getContents()
44
    {
45 1
        return file_get_contents($this->path);
46
    }
47
48
    /**
49
     * Returns md5 hash of the file.
50
     *
51
     * @return string
52
     */
53 1
    public function md5()
54
    {
55 1
        return md5_file($this->path);
56
    }
57
58
    /**
59
     * Returns an relative path to the file.
60
     *
61
     * @return string
62
     */
63 1
    public function path()
64
    {
65 1
        return $this->path;
66
    }
67
}
68