Passed
Push — master ( 3c6756...8b3b37 )
by Michael
20:43 queued 12:59
created

Field   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 20
c 2
b 0
f 0
dl 0
loc 46
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getRenderValue() 0 3 1
A render() 0 7 1
A __construct() 0 9 2
A init() 0 3 1
A renderBody() 0 3 1
A getUrlValue() 0 3 1
1
<?php
2
	/**
3
	 * @package Demos
4
	 */
5
	class Field
6
	{
7
		public $name;
8
		public $default;
9
		public $value;
10
		public $request;
11
		public $hint;
12
		
13
		function __construct($name, $default = null, $hint = '')
14
		{
15
			$this->name = $name;
16
			$this->default = $default;
17
			
18
			if ($hint == '')
19
				$hint = $name;
20
			
21
			$this->hint = $hint;
22
		}
23
		
24
		function init($request)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
		{
26
			$this->value = $request->get($this->name, $this->default);
27
		}
28
		
29
		function render()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
30
		{
31
			$id = htmlentities($this->name);
32
			echo '<label style="background-color: #c0c0c0; padding: 5px; margin: 2px;" for="imgparam_' . $id . '" title="' . htmlentities($this->hint) . '">';
33
			echo $this->name . ': ';
34
			$this->renderBody($id, 'imgparam_' . $id);
35
			echo '</label> ';
36
		}
37
		
38
		function renderBody($name, $id)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
39
		{
40
			echo '<input id="' . $id . '" type="text" size="15" name="' . $name . '" value="' . $this->getRenderValue() . '" />';
41
		}
42
		
43
		function getRenderValue()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
		{
45
			return $this->value;
46
		}
47
		
48
		function getUrlValue()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
49
		{
50
			return urlencode($this->name) . '=' . urlencode($this->value);
51
		}
52
	}
53