Completed
Pull Request — develop (#27)
by Chris
01:52
created

InfTransformer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 2
A doTransform() 0 9 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Transformer;
4
5
use Chrisyue\PhpM3u8\Document\Rfc8216\Tag\Inf;
6
7
/**
8
 * @Annotation
9
 */
10
class InfTransformer extends AbstractTransformer
11
{
12
    public function supports($origin)
13
    {
14
        return is_string($origin) && preg_match('/^\d+(\.\d+)?,/');
15
    }
16
17
    protected function doTransform($origin)
18
    {
19
        $inf = new Inf();
20
        list($duration, $inf->title) = explode(',', $origin, 2);
21
22
        $inf->duration = +$duration;
23
24
        return $inf;
25
    }
26
}
27