Passed
Branch tests1.5 (59f3fd)
by Wanderson
02:32
created

Html   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 2 1
A attributes() 0 6 2
A __construct() 0 3 1
1
<?php
2
3
namespace Win\Html;
4
5
/**
6
 * Elemento Html
7
 */
8
abstract class Html {
9
10
	/** @var string */
11
	protected $name;
12
13
	/** @var string[] */
14
	protected $attributes;
15
16
	/** @return string */
17
	abstract public function html();
18
19
	/**
20
	 * Cria o elemento
21
	 * @param string $name
22
	 * @param string[] $attributes
23
	 */
24
	public function __construct($name, $attributes) {
25
		$this->name = $name;
26
		$this->attributes = $attributes;
27
	}
28
29
	/** @return string */
30
	protected function attributes() {
31
		$html = '';
32
		foreach ($this->attributes as $name => $value) {
33
			$html .= $name . '="' . $value . '" ';
34
		}
35
		return $html;
36
	}
37
38
	/** @return string */
39
	public function __toString() {
40
		return $this->html();
41
	}
42
43
}
44