ID3v24   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFrameStatus() 0 6 1
A getFrameFormat() 0 8 1
A getFrameLength() 0 4 1
1
<?php
2
/**
3
 * Class ID3v24
4
 *
5
 * @created      22.09.2018
6
 * @author       smiley <[email protected]>
7
 * @copyright    2018 smiley
8
 * @license      MIT
9
 */
10
11
namespace chillerlan\ID3Tag;
12
13
use function unpack;
14
15
/**
16
 * @link http://id3.org/id3v2.4.0-changes
17
 * @link http://id3.org/id3v2.4.0-structure
18
 * @link http://id3.org/id3v2.4.0-frames
19
 */
20
class ID3v24 extends ID3v23{
21
22
	/**
23
	 *
24
	 */
25
	protected function getFrameLength(string $raw):int{
26
		$raw = unpack('N', $raw)[1];
27
28
		return ID3Helpers::syncSafeInteger($raw);
29
	}
30
31
	/**
32
	 *
33
	 */
34
	protected function getFrameFormat(int $flags):array{
35
		return [
36
			'flags'       => $flags,
37
			'length'      => (bool)($flags & 0b00000001),
38
			'unsync'      => (bool)($flags & 0b00000010),
39
			'encryption'  => (bool)($flags & 0b00000100),
40
			'compression' => (bool)($flags & 0b00001000),
41
			'grouping'    => (bool)($flags & 0b01000000),
42
		];
43
	}
44
45
	/**
46
	 *
47
	 */
48
	protected function getFrameStatus(int $flags):array{
49
		return [
50
			'flags'     => $flags,
51
			'read-only' => (bool)($flags & 0b00010000),
52
			'file'      => (bool)($flags & 0b00100000),
53
			'tag'       => (bool)($flags & 0b01000000),
54
		];
55
	}
56
57
}
58