cfg_factory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2019 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\services\blocks\config;
11
12
class cfg_factory
13
{
14
	/** @var array */
15
	private $fields;
16
17
	/**
18
	 * Constructor
19
	 *
20
	 * @param \phpbb\di\service_collection		$cfg_fields			Service Collection
21
	 */
22
	public function __construct(\phpbb\di\service_collection $cfg_fields)
23
	{
24
		$this->register_fields($cfg_fields);
25
	}
26
27
	/**
28
	 * @param \phpbb\di\service_collection $cfg_fields
29
	 */
30
	protected function register_fields(\phpbb\di\service_collection $cfg_fields)
31
	{
32
		$this->fields = array();
33
		foreach ($cfg_fields as $field)
34
		{
35
			$this->fields[$field->get_name()] = $field;
36
		}
37
	}
38
39
	/**
40
	 * Get field by name
41
	 *
42
	 * @param string $type
43
	 * @return false|\blitze\sitemaker\services\blocks\config\fields\cfg_field_interface
44
	 */
45
	public function get($type)
46
	{
47
		if (isset($this->fields[$type]))
48
		{
49
			return $this->fields[$type];
50
		}
51
52
		return false;
53
	}
54
}
55