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

UnsynchronisationFilter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 26
ccs 0
cts 4
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 4 1
A decode() 0 4 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\Filter;
9
10
/**
11
 * Unsynchronisation filter class.
12
 *
13
 * @package GravityMedia\Metadata\ID3v2\Filter
14
 */
15
class UnsynchronisationFilter
16
{
17
    /**
18
     * Encode data.
19
     *
20
     * @param string $data
21
     *
22
     * @return string
23
     */
24
    public function encode($data)
25
    {
26
        return preg_replace('/\xff(?=[\xe0-\xff])/', "\xff\x00", preg_replace('/\xff\x00/', "\xff\x00\x00", $data));
27
    }
28
29
    /**
30
     * Decode data.
31
     *
32
     * @param string $data
33
     *
34
     * @return string
35
     */
36
    public function decode($data)
37
    {
38
        return preg_replace('/\xff\x00\x00/', "\xff\x00", preg_replace('/\xff\x00(?=[\xe0-\xff])/', "\xff", $data));
39
    }
40
}
41