Completed
Push — id3-metadata-objects ( 384c4c...c855dc )
by Daniel
02:54
created

Tag::getVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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\InvalidArgumentException;
11
12
/**
13
 * ID3v2 tag class.
14
 *
15
 * @package GravityMedia\Metadata\ID3v2
16
 */
17
class Tag
18
{
19
    /**
20
     * @var int
21
     */
22
    protected $version;
23
24
    /**
25
     * @var int
26
     */
27
    protected $revision;
28
29
    /**
30
     * @var int
31
     */
32
    protected $padding;
33
34
    /**
35
     * @var int
36
     */
37
    protected $crc32;
38
39
    /**
40
     * @var int
41
     */
42
    protected $restrictions;
43
44
    /**
45
     * @var Frame[]
46
     */
47
    protected $frames;
48
49
    /**
50
     * Create ID3v2 tag object.
51
     *
52
     * @param int $version  The version (default is 3: v2.3)
53
     * @param int $revision The revision (default is 0)
54
     *
55
     * @throws InvalidArgumentException An exception is thrown on invalid version arguments
56
     */
57
    public function __construct($version = Version::VERSION_23, $revision = 0)
58
    {
59
        if (!in_array($version, Version::values(), true)) {
60
            throw new InvalidArgumentException('Invalid version.');
61
        }
62
63
        $this->version = $version;
64
        $this->revision = $revision;
65
        $this->padding = 0;
66
        $this->crc32 = 0;
67
        $this->restrictions = 0;
68
        $this->frames = [];
69
    }
70
71
    /**
72
     * Get version.
73
     *
74
     * @return int
75
     */
76
    public function getVersion()
77
    {
78
        return $this->version;
79
    }
80
81
    /**
82
     * Get revision.
83
     *
84
     * @return int
85
     */
86
    public function getRevision()
87
    {
88
        return $this->revision;
89
    }
90
91
    /**
92
     * Get padding.
93
     *
94
     * @return int
95
     */
96
    public function getPadding()
97
    {
98
        return $this->padding;
99
    }
100
101
    /**
102
     * Set padding.
103
     *
104
     * @param int $padding
105
     *
106
     * @return $this
107
     */
108
    public function setPadding($padding)
109
    {
110
        $this->padding = $padding;
111
112
        return $this;
113
    }
114
115
    /**
116
     * Get CRC-32.
117
     *
118
     * @return int
119
     */
120
    public function getCrc32()
121
    {
122
        return $this->crc32;
123
    }
124
125
    /**
126
     * Set CRC-32.
127
     *
128
     * @param int $crc32
129
     *
130
     * @return $this
131
     */
132
    public function setCrc32($crc32)
133
    {
134
        $this->crc32 = $crc32;
135
136
        return $this;
137
    }
138
139
    /**
140
     * Get restrictions.
141
     *
142
     * @return int
143
     */
144
    public function getRestrictions()
145
    {
146
        return $this->restrictions;
147
    }
148
149
    /**
150
     * Set restrictions
151
     *
152
     * @param int $restrictions
153
     *
154
     * @return $this
155
     */
156
    public function setRestrictions($restrictions)
157
    {
158
        $this->restrictions = $restrictions;
159
160
        return $this;
161
    }
162
163
    /**
164
     * Get frames
165
     *
166
     * @return Frame[]
167
     */
168
    public function getFrames()
169
    {
170
        return $this->frames;
171
    }
172
173
    /**
174
     * Add frame
175
     *
176
     * @param Frame $frame
177
     *
178
     * @return $this
179
     */
180
    public function addFrame(Frame $frame)
181
    {
182
        $this->frames[] = $frame;
183
184
        return $this;
185
    }
186
}
187