ConfigReader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 11
c 3
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 0 17 3
1
<?php
2
3
namespace FigTree\Config;
4
5
use Throwable;
6
use FigTree\Config\Contracts\ConfigReaderInterface;
7
use FigTree\Config\Exceptions\InvalidConfigFileException;
8
9
class ConfigReader implements ConfigReaderInterface
10
{
11
	/**
12
	 * Read the contents of the Config file.
13
	 *
14
	 * @return array
15
	 */
16
	public function read(string $filename): array
17
	{
18
		ob_start();
19
20
		try {
21
			$data = (require $filename);
22
		} catch (Throwable $exc) {
23
			throw new InvalidConfigFileException($filename, 0, $exc);
24
		} finally {
25
			ob_end_clean();
26
		}
27
28
		if (!is_array($data)) {
29
			throw new InvalidConfigFileException($filename);
30
		}
31
32
		return $data;
33
	}
34
}
35