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