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

FileStreamTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 58.06 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 18
loc 31
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testNext() 0 8 1
A testValid() 9 9 1
A testGetLine() 9 9 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\Stream;
4
5
use Chrisyue\PhpM3u8\Stream\FileStream;
6
use PHPUnit\Framework\TestCase;
7
8
class FileStreamTest extends TestCase
9
{
10
    public function testNext()
11
    {
12
        $prophecy = $this->prophesize(\SplFileObject::class);
13
        $prophecy->next()->shouldBeCalledTimes(1);
14
15
        $stream = new FileStream($prophecy->reveal());
16
        $stream->goNext();
17
    }
18
19 View Code Duplication
    public function testValid()
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...
20
    {
21
        $valid = (bool) rand(0, 1);
22
        $prophecy = $this->prophesize(\SplFileObject::class);
23
        $prophecy->valid()->shouldBeCalledTimes(1)->willReturn($valid);
24
25
        $stream = new FileStream($prophecy->reveal());
26
        $this->assertSame($valid, $stream->isValid());
27
    }
28
29 View Code Duplication
    public function testGetLine()
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...
30
    {
31
        $line = 'https://foo.bar/baz';
32
        $prophecy = $this->prophesize(\SplFileObject::class);
33
        $prophecy->current()->shouldBeCalled()->willReturn($line);
34
35
        $stream = new FileStream($prophecy->reveal());
36
        $this->assertSame($line, $stream->getLine());
37
    }
38
}
39