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

Demo::fval()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
	/**
3
	 * @package Demos
4
	 */
5
	class Demo
6
	{
7
		public $name;
8
		public $format = null;
9
		public $fields = array();
10
		public $order = 1000;
11
		
12
		function __construct($name)
13
		{
14
			$this->name = $name;
15
		}
16
		
17
		function init()
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...
18
		{
19
		}
20
		
21
		static function create($name)
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...
22
		{
23
			$file = DEMO_PATH . '/demos/' . $name . '.php';
24
			if (!file_exists($file))
25
				throw new Exception("Invalid demo: {$name}");
26
			include $file;
27
			$className = 'Demo_' . $name;
28
			$demo = new $className($name);
29
			$demo->request = Request::getInstance();
30
			$demo->init();
31
			foreach ($demo->fields as $field)
32
			{
33
				$field->request = Request::getInstance();
34
				$field->init(Request::getInstance());
35
			}
36
			return $demo;
37
		}
38
		
39
		function getFormat()
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...
40
		{
41
			return 'as input';
42
		}
43
		
44
		function addField($field)
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...
45
		{
46
			$this->fields[$field->name] = $field;
47
		}
48
		
49
		function __toString()
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...
50
		{
51
			return $this->name;
52
		}
53
		
54
		function text()
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...
55
		{
56
		}
57
		
58
		function fval($name)
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...
59
		{
60
			return $this->fields[$name]->value;
61
		}
62
	}
63