Completed
Branch MediaEmbedSiteConfig (7a33c9)
by Josh
03:32
created

SiteCollection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
ccs 17
cts 17
cp 1
wmc 6
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B asConfig() 0 24 6
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2016 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\MediaEmbed\Configurator\Collections;
9
10
use ArrayObject;
11
use s9e\TextFormatter\Configurator\ConfigProvider;
12
use s9e\TextFormatter\Configurator\JavaScript\Dictionary;
13
14
class SiteCollection extends ArrayObject implements ConfigProvider
15
{
16
	/**
17
	* {@inheritdoc}
18
	*/
19 4
	public function asConfig()
20
	{
21 4
		$map = [];
22 4
		foreach ($this as $siteId => $siteConfig)
23
		{
24 3
			if (isset($siteConfig['host']))
25 3
			{
26 2
				foreach ((array) $siteConfig['host'] as $host)
27
				{
28 2
					$map[$host] = $siteId;
29 2
				}
30 2
			}
31
32 3
			if (isset($siteConfig['scheme']))
33 3
			{
34 1
				foreach ((array) $siteConfig['scheme'] as $scheme)
35
				{
36 1
					$map[$scheme . ':'] = $siteId;
37 1
				}
38 1
			}
39 4
		}
40
41 4
		return new Dictionary($map);
42
	}
43
}