Completed
Pull Request — develop (#27)
by Chris
02:25
created

ByterangeTranformerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 59.38 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 19
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testTransform() 0 6 1
A dataProvider() 19 19 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Chrisyue\PhpM3u8\Tests\M3u8\Transformer;
4
5
use Chrisyue\PhpM3u8\Document\Rfc8216\Tag;
6
use PHPUnit\Framework\TestCase;
7
use Chrisyue\PhpM3u8\Transformer\ByterangeTransformer;
8
9
class ByterangeTranformerTest extends TestCase
10
{
11
    /**
12
     * @dataProvider dataProvider
13
     */
14
    public function testTransform($origin, $transformed)
15
    {
16
        $transformer = new ByterangeTransformer();
17
18
        $this->assertEquals($transformed, $transformer->transform($origin));
19
    }
20
21 View Code Duplication
    public function dataProvider()
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...
22
    {
23
        $data = [];
24
25
        $origin = '100';
26
        $transformed = new Tag\Byterange();
27
        $transformed->length = 100;
28
29
        $data[] = [$origin, $transformed];
30
31
        $origin = '222@333';
32
        $transformed = new Tag\Byterange();
33
        $transformed->length = 222;
34
        $transformed->offset = 333;
35
36
        $data[] = [$origin, $transformed];
37
38
        return $data;
39
    }
40
}
41