Completed
Push — id3-metadata-objects ( e55453...161f4c )
by Daniel
11:12
created

Metadata::strip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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