cfg_factory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 8 2
A register_fields() 0 6 2
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