FileDriver::getPaths()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Arthem\GraphQLMapper\Mapping\Driver;
4
5
abstract class FileDriver implements DriverInterface
6
{
7
    /**
8
     * @var FilePathAccessorInterface
9
     */
10
    private $pathAccessor;
11
12
    /**
13
     * @param array|string|FilePathAccessorInterface $files
14
     */
15
    public function __construct($files)
16
    {
17
        if ($files instanceof FilePathAccessorInterface) {
18
            $this->pathAccessor = $files;
19
        } else {
20
            $this->pathAccessor = new DefaultFilePathAccessor((array)$files);
21
        }
22
    }
23
24
    /**
25
     * @param string $path
26
     * @return string
27
     */
28
    protected function getFileContent($path)
29
    {
30
        if (!is_file($path)) {
31
            throw new \Exception(sprintf('File "%s" not found', $path));
32
        }
33
34
        return file_get_contents($path);
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    protected function getPaths()
41
    {
42
        return $this->pathAccessor->getPaths();
43
    }
44
}
45