VersionTag   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setVersion() 6 6 1
A getVersion() 4 4 1
A dump() 4 4 1
A read() 4 4 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
/*
4
 * This file is part of the PhpM3u8 package.
5
 *
6
 * (c) Chrisyue <http://chrisyue.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Chrisyue\PhpM3u8\Tag;
13
14 View Code Duplication
class VersionTag extends AbstractTag
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
    use SingleValueTagTrait;
17
18
    private $version = 3;
19
20
    const TAG_IDENTIFIER = '#EXT-X-VERSION';
21
22 1
    public function setVersion($version)
23
    {
24 1
        $this->version = $version;
25
26 1
        return $this;
27
    }
28
29 1
    public function getVersion()
30
    {
31 1
        return $this->version;
32
    }
33
34 1
    public function dump()
35
    {
36 1
        return sprintf('%s:%d', self::TAG_IDENTIFIER, $this->version);
37
    }
38
39 1
    protected function read($line)
40
    {
41 1
        $this->version = (int) self::extractValue($line);
42 1
    }
43
}
44