Completed
Push — vendor/getid3 ( e63377...69b815 )
by Pauli
03:29
created

getid3_xz::Analyze()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 4
Ratio 23.53 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 4
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
/////////////////////////////////////////////////////////////////
4
/// getID3() by James Heinrich <[email protected]>               //
5
//  available at https://github.com/JamesHeinrich/getID3       //
6
//            or https://www.getid3.org                        //
7
//            or http://getid3.sourceforge.net                 //
8
//  see readme.txt for more details                            //
9
/////////////////////////////////////////////////////////////////
10
//                                                             //
11
// module.archive.xz.php                                       //
12
// module for analyzing XZ files                               //
13
// dependencies: NONE                                          //
14
//                                                            ///
15
/////////////////////////////////////////////////////////////////
16
17
18
class getid3_xz extends getid3_handler
19
{
20
21
	/**
22
	 * @return bool
23
	 */
24
	public function Analyze() {
25
		$info = &$this->getid3->info;
26
27
		$this->fseek($info['avdataoffset']);
28
		$xzheader = $this->fread(6);
29
30
		// https://tukaani.org/xz/xz-file-format-1.0.4.txt
31
		$info['xz']['stream_header']['magic'] = substr($xzheader, 0, 6);
32 View Code Duplication
		if ($info['xz']['stream_header']['magic'] != "\xFD".'7zXZ'."\x00") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
			$this->error('Invalid XZ stream header magic (expecting FD 37 7A 58 5A 00, found '.getid3_lib::PrintHexBytes($info['xz']['stream_header']['magic']).') at offset '.$info['avdataoffset']);
34
			return false;
35
		}
36
		$info['fileformat'] = 'xz';
37
		$this->error('XZ parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
38
		return false;
39
40
	}
41
42
}
43