FileLocator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 51
wmc 5
lcom 1
cbo 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A readFile() 0 4 1
A getFile() 0 4 1
A getExtension() 0 4 1
1
<?php
2
/*
3
 * This file is part of the Borobudur-Config package.
4
 *
5
 * (c) Hexacodelabs <http://hexacodelabs.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Borobudur\Config\FileLoader;
12
13
use Borobudur\Config\Exception\Exception;
14
15
/**
16
 * @author      Iqbal Maulana <[email protected]>
17
 * @created     8/12/15
18
 */
19
class FileLocator
20
{
21
    /**
22
     * @var string
23
     */
24
    private $file;
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param string $file
30
     */
31
    public function __construct($file)
32
    {
33
        if (!file_exists($file)) {
34
            throw new Exception(sprintf('File "%s" not found.', $file));
35
        }
36
37
        $this->file = $file;
38
    }
39
40
    /**
41
     * Read file content.
42
     *
43
     * @return string
44
     */
45
    public function readFile()
46
    {
47
        return file_get_contents($this->file);
48
    }
49
50
    /**
51
     * Get file.
52
     *
53
     * @return string
54
     */
55
    public function getFile()
56
    {
57
        return $this->file;
58
    }
59
60
    /**
61
     * Get file extension.
62
     *
63
     * @return string
64
     */
65
    public function getExtension()
66
    {
67
        return pathinfo($this->file, PATHINFO_EXTENSION);
68
    }
69
}
70