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

InfTransformer::supports()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 2
eloc 2
nc 2
nop 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