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

Demo   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 22
c 2
b 0
f 0
dl 0
loc 56
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 16 3
A init() 0 2 1
A __construct() 0 3 1
A text() 0 2 1
A fval() 0 3 1
A addField() 0 3 1
A __toString() 0 3 1
A getFormat() 0 3 1
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