Completed
Push — id3-metadata-objects ( a3a88a...ecc500 )
by Daniel
03:22
created

Header::setSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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
use GravityMedia\Metadata\ID3v2\Enum\Version;
12
use GravityMedia\Metadata\ID3v2\HeaderInterface;
13
14
/**
15
 * ID3v2 header
16
 *
17
 * @package GravityMedia\Metadata
18
 */
19
class Header implements HeaderInterface
20
{
21
    /**
22
     * @var int
23
     */
24
    protected $version;
25
26
    /**
27
     * @var int
28
     */
29
    protected $revision;
30
31
    /**
32
     * @var array
33
     */
34
    protected $flags;
35
36
    /**
37
     * @var int
38
     */
39
    protected $size;
40
41
    /**
42
     * Create header object.
43
     *
44
     * @param int $version The version (default is 3: v2.3)
45
     *
46
     * @throws InvalidArgumentException An exception is thrown on invalid version arguments
47
     */
48 View Code Duplication
    public function __construct($version = Version::VERSION_23)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
49
    {
50
        if (!in_array($version, Version::values())) {
51
            throw new InvalidArgumentException('Invalid version.');
52
        }
53
54
        $this->version = $version;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getVersion()
61
    {
62
        return $this->version;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function getRevision()
69
    {
70
        return $this->revision;
71
    }
72
73
    /**
74
     * Set revision
75
     *
76
     * @param int $revision
77
     *
78
     * @return $this
79
     */
80
    public function setRevision($revision)
81
    {
82
        $this->revision = $revision;
83
        return $this;
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function isFlagEnabled($flag)
90
    {
91
        if (isset($this->flags[$flag])) {
92
            return $this->flags[$flag];
93
        }
94
95
        return false;
96
    }
97
98
    /**
99
     * Set flags
100
     *
101
     * @param array $flags
102
     *
103
     * @return $this
104
     */
105
    public function setFlags(array $flags)
106
    {
107
        $this->flags = $flags;
108
        return $this;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114
    public function getSize()
115
    {
116
        return $this->size;
117
    }
118
119
    /**
120
     * Set size in bytes
121
     *
122
     * @param int $size
123
     *
124
     * @return $this
125
     */
126
    public function setSize($size)
127
    {
128
        $this->size = $size;
129
        return $this;
130
    }
131
}
132