Completed
Branch master (0fc797)
by Michael
13:18 queued 09:16
created

AdminerDumpBz2::_bz2()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 10
rs 9.4285
1
<?php
2
3
/** Dump to Bzip2 format
4
* @link https://www.adminer.org/plugins/#use
5
* @uses bzopen(), tempnam("")
6
* @author Jakub Vrana, http://www.vrana.cz/
7
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
8
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
9
*/
10
class AdminerDumpBz2 {
11
	/** @access protected */
12
	var $filename, $fp;
13
	
14
	function dumpOutput() {
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...
15
		if (!function_exists('bzopen')) {
16
			return array();
17
		}
18
		return array('bz2' => 'bzip2');
19
	}
20
	
21
	function _bz2($string, $state) {
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
		bzwrite($this->fp, $string);
23
		if ($state & PHP_OUTPUT_HANDLER_END) {
24
			bzclose($this->fp);
25
			$return = file_get_contents($this->filename);
26
			unlink($this->filename);
27
			return $return;
28
		}
29
		return '';
30
	}
31
	
32
	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...
33
		if ($_POST['output'] == 'bz2') {
34
			$this->filename = tempnam('', 'bz2');
35
			$this->fp = bzopen($this->filename, 'w');
36
			header('Content-Type: application/x-bzip');
37
			ob_start(array($this, '_bz2'), 1e6);
38
		}
39
	}
40
41
}
42