Completed
Push — master ( 14c945...6811c1 )
by Henry
05:37
created

Meta::render()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.5069

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 8
cts 11
cp 0.7272
rs 9.1768
c 0
b 0
f 0
cc 5
nc 3
nop 0
crap 5.5069
1
<?php
2
namespace Redaxscript\Head;
3
4
use Redaxscript\Html;
5
6
/**
7
 * children class to create the meta tag
8
 *
9
 * @since 3.0.0
10
 *
11
 * @package Redaxscript
12
 * @category Head
13
 * @author Henry Ruhs
14
 * @author Balázs Szilágyi
15
 */
16
17
class Meta extends HeadAbstract
18
{
19
	/**
20
	 * render the meta
21
	 *
22
	 * @since 3.0.0
23
	 *
24
	 * @return string|null
25
	 */
26
27 1
	public function render() : ?string
28
	{
29 1
		$output = null;
30
31
		/* html element */
32
33 1
		$metaElement = new Html\Element();
34 1
		$metaElement->init('meta');
35
36
		/* handle collection */
37
38 1
		$collectionArray = $this->_getCollectionArray();
39
40
		/* process collection */
41
42 1
		foreach ($collectionArray as $attribute)
43
		{
44
			if ($attribute['content'] && $attribute['name'] || !$attribute['name'])
45
			{
46
				$output .= $metaElement
47
					->copy()
48
					->attr($attribute);
49
			}
50
		}
51 1
		$this->clear();
52 1
		return $output;
53
	}
54
}