Passed
Branch v1.4.0 (ac3196)
by Wanderson
01:13
created

Checkbox   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A html() 0 3 1
A check() 0 3 2
A __construct() 0 3 1
1
<?php
2
3
namespace Win\Html\Form;
4
5
/**
6
 * Checkbox
7
 * <input type="checkbox">
8
 */
9
class Checkbox extends Input
10
{
11
	/**
12
	 * Retorna 'checked' se os valores são iguais
13
	 * @param mixed $value1
14
	 * @param mixed $value2
15
	 * @return string
16
	 */
17
	public static function check($value1, $value2 = true)
18
	{
19
		return ($value1 == $value2) ? 'checked ' : '';
20
	}
21
22
	/**
23
	 * @param string $name
24
	 * @param mixed $value
25
	 * @param string[] $attributes
26
	 */
27
	public function __construct($name, $value = '', $attributes = [])
28
	{
29
		parent::__construct('checkbox', $name, $value, $attributes);
30
	}
31
32
	/** @return string */
33
	public function html()
34
	{
35
		return '<input type="checkbox" />';
36
	}
37
}
38