| @@ 20-38 (lines=19) @@ | ||
| 17 | use Chrisyue\PhpM3u8\Line\Lines; |
|
| 18 | use Chrisyue\PhpM3u8\Stream\StreamInterface; |
|
| 19 | ||
| 20 | class DumperFacade |
|
| 21 | { |
|
| 22 | private $dumper; |
|
| 23 | ||
| 24 | public function dump(\ArrayObject $data, StreamInterface $stream) |
|
| 25 | { |
|
| 26 | if (null === $this->dumper) { |
|
| 27 | $rootPath = realpath(__DIR__.'/../..'); |
|
| 28 | $tagDefinitions = new TagDefinitions(require $rootPath.'/resources/definitions/tags.php'); |
|
| 29 | ||
| 30 | $this->dumper = new Dumper( |
|
| 31 | $tagDefinitions, |
|
| 32 | new Config(require $rootPath.'/resources/definitions/tagValueDumpers.php') |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | ||
| 36 | $this->dumper->dumpToLines($data, new Lines($stream)); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 21-40 (lines=20) @@ | ||
| 18 | use Chrisyue\PhpM3u8\Parser\Parser; |
|
| 19 | use Chrisyue\PhpM3u8\Stream\StreamInterface; |
|
| 20 | ||
| 21 | class ParserFacade |
|
| 22 | { |
|
| 23 | private $parser; |
|
| 24 | ||
| 25 | public function parse(StreamInterface $stream) |
|
| 26 | { |
|
| 27 | if (null === $this->parser) { |
|
| 28 | $rootPath = realpath(__DIR__.'/../..'); |
|
| 29 | $tagDefinitions = new TagDefinitions(require $rootPath.'/resources/definitions/tags.php'); |
|
| 30 | ||
| 31 | $this->parser = new Parser( |
|
| 32 | $tagDefinitions, |
|
| 33 | new Config(require $rootPath.'/resources/definitions/tagValueParsers.php'), |
|
| 34 | new DataBuilder() |
|
| 35 | ); |
|
| 36 | } |
|
| 37 | ||
| 38 | return $this->parser->parse(new Lines($stream)); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||