Completed
Pull Request — develop (#30)
by
unknown
02:43
created

ProgramDateTimeTag   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 20%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setProgramDateTime() 6 6 1
A getProgramDateTime() 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
/**
15
 * Class ProgramDateTimeTag
16
 */
17 View Code Duplication
class ProgramDateTimeTag 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...
18
{
19
    use SingleValueTagTrait;
20
21
    const TAG_IDENTIFIER = '#EXT-X-PROGRAM-DATE-TIME';
22
23
    /**
24
     * @var string Absolute date and/or time of the first sample of the Media Segment in ISO_8601 format
25
     */
26
    private $programDateTime;
27
28
    /**
29
     * @param string $programDateTime
30
     * @return $this
31
     */
32
    public function setProgramDateTime($programDateTime)
33
    {
34
        $this->programDateTime = $programDateTime;
35
36
        return $this;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getProgramDateTime()
43
    {
44
        return $this->programDateTime;
45
    }
46
47
    /**
48
     * @return string
49
     */
50 1
    public function dump()
51
    {
52 1
        return sprintf('%s:%d', self::TAG_IDENTIFIER, $this->programDateTime);
53
    }
54
55
    /**
56
     * @param string $line
57
     */
58
    protected function read($line)
59
    {
60
        $this->programDateTime = self::extractValue($line);
61
    }
62
}
63