AdminerDumpXml   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 48
rs 10
wmc 13
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A dumpFormat() 0 3 1
A dumpTable() 0 5 2
A _database() 0 3 1
B dumpData() 0 21 7
A dumpHeaders() 0 6 2
1
<?php
2
3
/** Dump to XML format in structure <database name=""><table name=""><column name="">value
4
* @link https://www.adminer.org/plugins/#use
5
* @author Jakub Vrana, http://www.vrana.cz/
6
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
7
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
8
*/
9
class AdminerDumpXml {
10
	/** @access protected */
11
	var $database = false;
12
	
13
	function dumpFormat() {
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...
14
		return array('xml' => 'XML');
15
	}
16
17
	function dumpTable($table, $style, $is_view = false) {
0 ignored issues
show
Unused Code introduced by
The parameter $table is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $style is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $is_view is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
		if ($_POST['format'] == 'xml') {
19
			return true;
20
		}
21
	}
22
	
23
	function _database() {
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...
24
		echo "</database>\n";
25
	}
26
	
27
	function dumpData($table, $style, $query) {
0 ignored issues
show
Unused Code introduced by
The parameter $style is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
28
		if ($_POST['format'] == 'xml') {
29
			if (!$this->database) {
30
				$this->database = true;
31
				echo "<database name='" . h(DB) . "'>\n";
32
				register_shutdown_function(array($this, '_database'));
33
			}
34
			$connection = connection();
35
			$result = $connection->query($query, 1);
36
			if ($result) {
37
				while ($row = $result->fetch_assoc()) {
38
					echo "\t<table name='" . h($table) . "'>\n";
39
					foreach ($row as $key => $val) {
40
						echo "\t\t<column name='" . h($key) . "'" . (isset($val) ? '' : " null='null'") . '>' . h($val) . "</column>\n";
41
					}
42
					echo "\t</table>\n";
43
				}
44
			}
45
			return true;
46
		}
47
	}
48
49
	function dumpHeaders($identifier, $multi_table = false) {
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $multi_table is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
		if ($_POST['format'] == 'xml') {
51
			header('Content-Type: text/xml; charset=utf-8');
52
			return 'xml';
53
		}
54
	}
55
56
}
57