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

Metadata::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 2
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\ID3v2\Reader\TagReader;
11
use GravityMedia\Metadata\Metadata\MetadataInterface;
12
use GravityMedia\Stream\StreamInterface;
13
14
/**
15
 * ID3v2 metadata.
16
 *
17
 * @package GravityMedia\Metadata\ID3v2
18
 */
19
class Metadata implements MetadataInterface
20
{
21
    /**
22
     * @var StreamInterface
23
     */
24
    protected $stream;
25
26
    /**
27
     * @var TagReader
28
     */
29
    protected $tagReader;
30
31
    /**
32
     * Create ID3v2 metadata.
33
     *
34
     * @param StreamInterface $stream
35
     */
36
    public function __construct(StreamInterface $stream)
37
    {
38
        $this->stream = $stream;
39
    }
40
41
    /**
42
     * Get tag reader.
43
     *
44
     * @return TagReader
45
     */
46
    public function getTagReader()
47
    {
48
        if (null === $this->tagReader) {
49
            $this->tagReader = new TagReader($this, $this->stream);
50
        }
51
52
        return $this->tagReader;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 View Code Duplication
    public function exists()
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...
59
    {
60
        if ($this->stream->getSize() < 10) {
61
            return false;
62
        }
63
64
        $this->stream->seek(0);
65
66
        return 'ID3' === $this->stream->read(3);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function strip()
73
    {
74
        // TODO: implement
75
76
        return $this;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function read()
83
    {
84
        return $this->getTagReader()->read();
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function write(Tag $tag)
91
    {
92
        // TODO: implement
93
94
        return $this;
95
    }
96
}
97