Completed
Pull Request — develop (#89)
by Jaap
04:24
created

LocalFile::getContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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
    public function __construct($path)
34
    {
35
        $this->path = $path;
36
    }
37
38
    /**
39
     * Returns the content of the file as a string.
40
     *
41
     * @return string
42
     */
43
    public function getContents()
44
    {
45
        return file_get_contents($this->path);
46
    }
47
48
    /**
49
     * Returns md5 hash of the file.
50
     *
51
     * @return string
52
     */
53
    public function md5()
54
    {
55
        return md5_file($this->path);
56
    }
57
58
    /**
59
     * Returns an relative path to the file.
60
     *
61
     * @return string
62
     */
63
    public function path()
64
    {
65
        return $this->path;
66
    }
67
}
68