Completed
Pull Request — master (#37)
by Chris
02:41
created

Php::__construct()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 8.8571
cc 5
eloc 7
nc 3
nop 1
1
<?php
2
namespace Darya\Foundation\Configuration;
3
4
use Darya\Foundation\AbstractConfiguration;
5
6
/**
7
 * Darya's PHP file configuration implementation.
8
 * 
9
 * @author Chris Andrew <[email protected]>
10
 */
11
class Php extends AbstractConfiguration
12
{
13
	/**
14
	 * Build a new configuration from the PHP files at the given paths.
15
	 * 
16
	 * @param array|string $paths
17
	 */
18
	public function __construct($paths)
19
	{
20
		$data = array();
21
		$paths = (array) $paths;
22
		
23
		foreach ($paths as $path) {
24
			if (is_file($path) && preg_match('/\.php$/', $path)) {
25
				$data = array_merge($data, include $path ?: array());
26
			}
27
		}
28
		
29
		$this->data = $data;
30
	}
31
}
32