FileReader   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A read() 0 8 2
A fileExists() 0 4 1
A getFileContent() 0 4 1
1
<?php
2
3
namespace IgnoreFiles\Infrastructure\Disk;
4
5
class FileReader
6
{
7
    /**
8
     * @var string
9
     */
10
    private $file;
11
12
    /**
13
     * FileReader constructor.
14
     *
15
     * @param string $file
16
     */
17
    public function __construct($file)
18
    {
19
        $this->file = $file;
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function read()
26
    {
27
        if (false === $this->fileExists()) {
28
            return [];
29
        }
30
31
        return $this->getFileContent();
32
    }
33
34
    /**
35
     * @return bool
36
     */
37
    private function fileExists()
38
    {
39
        return file_exists($this->file);
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    private function getFileContent()
46
    {
47
        return file($this->file);
48
    }
49
50
51
}
52