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

UriAwareAttrTagParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Parser;
4
5
use Chrisyue\PhpM3u8\Line\LinesInterface;
6
use Chrisyue\PhpM3u8\Line\LineInterface;
7
use Chrisyue\PhpM3u8\Transformer\AttrListTransformer;
8
9
class UriAwareAttrTagParser extends TagParser
10
{
11
    private $uriParser;
12
13
    private $dataAccessor;
14
15
    public function __construct(
16
        LineInterface $line,
17
        AttrListTransformer $transformer = null,
18
        ChildParserInterface $uriParser,
19
        $repeatable = false
20
    ) {
21
        parent::__construct($line, $transformer, $repeatable);
22
23
        $this->uriParser = $uriParser;
24
        $this->dataAccessor = $transformer->getDataAccessor();
0 ignored issues
show
Bug introduced by
It seems like $transformer is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
25
    }
26
27
    public function parse(LinesInterface $lines)
28
    {
29
        parent::parse($lines);
30
        $lines->goNext();
31
        $this->dataAccessor->set('uri', $this->uriParser->parse($lines));
32
33
        return $this->dataAccessor->getData();
34
    }
35
36
    public function supports(LineInterface $line)
37
    {
38
        return parent::supports($line);
39
    }
40
41
    public function isRepeatable()
42
    {
43
        return true;
44
    }
45
}
46