Completed
Pull Request — develop (#126)
by Chuck
10:27 queued 08:42
created

LocalFile::path()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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