|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Metadata package. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Daniel Schröder <[email protected]> |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace GravityMedia\Metadata\ID3v2; |
|
9
|
|
|
|
|
10
|
|
|
use GravityMedia\Metadata\Exception\BadMethodCallException; |
|
11
|
|
|
use GravityMedia\Metadata\ID3v2\Enum\Version; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* ID3v2 tag |
|
15
|
|
|
* |
|
16
|
|
|
* @package GravityMedia\Metadata\ID3v2 |
|
17
|
|
|
*/ |
|
18
|
|
|
class Tag implements TagInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var HeaderInterface |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $header; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var ExtendedHeader |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $extendedHeader; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var FrameInterface[] |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $frames; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Create tag object. |
|
37
|
|
|
* |
|
38
|
|
|
* @param HeaderInterface $header |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct(HeaderInterface $header) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->header = $header; |
|
43
|
|
|
$this->frames = new \ArrayObject(); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get header |
|
48
|
|
|
* |
|
49
|
|
|
* @return HeaderInterface |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getHeader() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->header; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get extended header |
|
58
|
|
|
* |
|
59
|
|
|
* @return ExtendedHeader |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getExtendedHeader() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->extendedHeader; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Set extended header |
|
68
|
|
|
* |
|
69
|
|
|
* @param ExtendedHeaderInterface $extendedHeader |
|
70
|
|
|
* |
|
71
|
|
|
* @throws BadMethodCallException An exception is thrown on ID3 v2.2 tag |
|
72
|
|
|
* |
|
73
|
|
|
* @return $this |
|
74
|
|
|
*/ |
|
75
|
|
|
public function setExtendedHeader(ExtendedHeaderInterface $extendedHeader) |
|
76
|
|
|
{ |
|
77
|
|
|
if (!in_array($this->getVersion(), [Version::VERSION_23, Version::VERSION_24])) { |
|
78
|
|
|
throw new BadMethodCallException('Extended header is not supported in this version.'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$this->extendedHeader = $extendedHeader; |
|
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
return $this; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* {@inheritdoc} |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getVersion() |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->header->getVersion(); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* {@inheritdoc} |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getFrames() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->frames; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Add frame |
|
104
|
|
|
* |
|
105
|
|
|
* @param FrameInterface $frame |
|
106
|
|
|
* |
|
107
|
|
|
* @return $this |
|
108
|
|
|
*/ |
|
109
|
|
|
public function addFrame(FrameInterface $frame) |
|
110
|
|
|
{ |
|
111
|
|
|
$this->frames->append($frame); |
|
|
|
|
|
|
112
|
|
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..