| Conditions | 3 |
| Paths | 3 |
| Total Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 26 | public function Analyze() { |
||
| 27 | $info = &$this->getid3->info; |
||
| 28 | |||
| 29 | $info['fileformat'] = 'hpk'; |
||
| 30 | |||
| 31 | $this->fseek($info['avdataoffset']); |
||
| 32 | $HPKheader = $this->fread(36); |
||
| 33 | |||
| 34 | if (substr($HPKheader, 0, 4) == 'BPUL') { |
||
| 35 | |||
| 36 | $info['hpk']['header']['signature'] = substr($HPKheader, 0, 4); |
||
| 37 | $info['hpk']['header']['data_offset'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 4, 4)); |
||
| 38 | $info['hpk']['header']['fragments_per_file'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 8, 4)); |
||
| 39 | //$info['hpk']['header']['unknown1'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 12, 4)); |
||
| 40 | $info['hpk']['header']['fragments_residual_offset'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 16, 4)); |
||
| 41 | $info['hpk']['header']['fragments_residual_count'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 20, 4)); |
||
| 42 | //$info['hpk']['header']['unknown2'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 24, 4)); |
||
| 43 | $info['hpk']['header']['fragmented_filesystem_offset'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 28, 4)); |
||
| 44 | $info['hpk']['header']['fragmented_filesystem_length'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 32, 4)); |
||
| 45 | |||
| 46 | $info['hpk']['header']['filesystem_entries'] = $info['hpk']['header']['fragmented_filesystem_length'] / ($info['hpk']['header']['fragments_per_file'] * 8); |
||
| 47 | $this->fseek($info['hpk']['header']['fragmented_filesystem_offset']); |
||
| 48 | for ($i = 0; $i < $info['hpk']['header']['filesystem_entries']; $i++) { |
||
| 49 | $offset = getid3_lib::LittleEndian2Int($this->fread(4)); |
||
|
|
|||
| 50 | $length = getid3_lib::LittleEndian2Int($this->fread(4)); |
||
| 51 | $info['hpk']['filesystem'][$i] = array('offset' => $offset, 'length' => $length); |
||
| 52 | } |
||
| 53 | |||
| 54 | $this->error('HPK parsing incomplete (and mostly broken) in this version of getID3() ['.$this->getid3->version().']'); |
||
| 55 | |||
| 56 | /* |
||
| 57 | $filename = ''; |
||
| 58 | $dirs = array(); |
||
| 59 | foreach ($info['hpk']['filesystem'] as $key => $filesystemdata) { |
||
| 60 | $this->fseek($filesystemdata['offset']); |
||
| 61 | $first4 = $this->fread(4); |
||
| 62 | if (($first4 == 'LZ4 ') || ($first4 == 'ZLIB')) { |
||
| 63 | // actual data, ignore |
||
| 64 | $info['hpk']['toc'][$key] = array( |
||
| 65 | 'filename' => ltrim(implode('/', $dirs).'/'.$filename, '/'), |
||
| 66 | 'offset' => $filesystemdata['offset'], |
||
| 67 | 'length' => $filesystemdata['length'], |
||
| 68 | ); |
||
| 69 | $filename = ''; |
||
| 70 | $dirs = array(); |
||
| 71 | } else { |
||
| 72 | $fragment_index = getid3_lib::LittleEndian2Int($first4); |
||
| 73 | $fragment_type = getid3_lib::LittleEndian2Int($this->fread(4)); // file = 0, directory = 1 |
||
| 74 | $name_length = getid3_lib::LittleEndian2Int($this->fread(2)); |
||
| 75 | if ($fragment_type == 1) { |
||
| 76 | $dirs[] = $this->fread($name_length); |
||
| 77 | } else { |
||
| 78 | $filename = $this->fread($name_length); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | } |
||
| 82 | */ |
||
| 83 | |||
| 84 | } else { |
||
| 85 | $this->error('Expecting "BPUL" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($HPKheader, 0, 4)).'"'); |
||
| 86 | return false; |
||
| 87 | } |
||
| 88 | |||
| 89 | return true; |
||
| 90 | } |
||
| 91 | |||
| 93 |