1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
-
-
-
- namespace Exporter;
-
- use Exporter\Source\SourceIteratorInterface;
- use Exporter\Writer\WriterInterface;
-
- class Handler
- {
- protected $source;
-
- protected $writer;
-
-
-
- public function __construct(SourceIteratorInterface $source, WriterInterface $writer)
- {
- $this->source = $source;
- $this->writer = $writer;
- }
-
-
-
- public function export()
- {
- $this->writer->open();
-
- foreach ($this->source as $data) {
- $this->writer->write($data);
- }
-
- $this->writer->close();
- }
-
-
-
- public static function create(SourceIteratorInterface $source, WriterInterface $writer)
- {
- return new self($source, $writer);
- }
- }
|