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

getid3_xz   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 16 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 4
loc 25
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A Analyze() 4 17 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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