|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Chrisyue\PhpM3u8\PdFactory; |
|
4
|
|
|
|
|
5
|
|
|
use Chrisyue\PhpM3u8\DataAccessor\ObjectAccessor; |
|
6
|
|
|
use Chrisyue\PhpM3u8\Parser\Strategy\PlaylistStrategy; |
|
7
|
|
|
use Chrisyue\PhpM3u8\PdFactory\PdFactoryInterface; |
|
8
|
|
|
use Chrisyue\PhpM3u8\PropertyReader\PropertyReaderInterface; |
|
9
|
|
|
use Chrisyue\PhpM3u8\Parser\Parsers; |
|
10
|
|
|
use Chrisyue\PhpM3u8\Parser\ParentParser; |
|
11
|
|
|
use Chrisyue\PhpM3u8\DataAccessor\Factory; |
|
12
|
|
|
use Chrisyue\PhpM3u8\Line\LinesAwareInterface; |
|
13
|
|
|
use Chrisyue\PhpM3u8\Line\LinesInterface; |
|
14
|
|
|
use Chrisyue\PhpM3u8\Dumper\ParentDumper; |
|
15
|
|
|
|
|
16
|
|
|
class AnnotReadablePlaylistPdFactory extends AbstractParentAnnotReadableFactory |
|
17
|
|
|
{ |
|
18
|
|
|
private $class; |
|
19
|
|
|
|
|
20
|
|
|
private $lines; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct(PropertyReaderInterface $reader, $class, LinesInterface $lines = null) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->setReader($reader); |
|
25
|
|
|
$this->class = $class; |
|
26
|
|
|
$this->lines = $lines; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function createParser() |
|
30
|
|
|
{ |
|
31
|
|
|
$parsers = new Parsers(); |
|
32
|
|
|
$this->iterateFactories($this->class, function ($key, PdFactoryInterface $factory) use ($parsers) { |
|
33
|
|
|
$parsers->set($key, $factory->createParser()); |
|
34
|
|
|
}); |
|
35
|
|
|
|
|
36
|
|
|
return new ParentParser($parsers, new ObjectAccessor(new $this->class), new PlaylistStrategy()); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function createDumper() |
|
40
|
|
|
{ |
|
41
|
|
|
$dumpers = []; |
|
42
|
|
|
$this->iterateFactories($this->class, function ($key, PdFactoryInterface $factory) use (&$dumpers) { |
|
43
|
|
|
if ($factory instanceof LinesAwareInterface) { |
|
44
|
|
|
$factory->setLines($this->lines); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$dumpers[$key] = $factory->createDumper(); |
|
48
|
|
|
}); |
|
49
|
|
|
|
|
50
|
|
|
return new ParentDumper(new Factory(), $dumpers); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|