Mercurial > hg > isophonics-drupal-site
annotate vendor/masterminds/html5/src/HTML5/Parser/FileInputStream.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 namespace Masterminds\HTML5\Parser; |
Chris@0 | 3 |
Chris@0 | 4 /** |
Chris@0 | 5 * The FileInputStream loads a file to be parsed. |
Chris@0 | 6 * |
Chris@0 | 7 * So right now we read files into strings and then process the |
Chris@0 | 8 * string. We chose to do this largely for the sake of expediency of |
Chris@0 | 9 * development, and also because we could optimize toward processing |
Chris@0 | 10 * arbitrarily large chunks of the input. But in the future, we'd |
Chris@0 | 11 * really like to rewrite this class to efficiently handle lower level |
Chris@0 | 12 * stream reads (and thus efficiently handle large documents). |
Chris@0 | 13 * |
Chris@0 | 14 * @todo A buffered input stream would be useful. |
Chris@0 | 15 */ |
Chris@0 | 16 class FileInputStream extends StringInputStream implements InputStream |
Chris@0 | 17 { |
Chris@0 | 18 |
Chris@0 | 19 /** |
Chris@0 | 20 * Load a file input stream. |
Chris@0 | 21 * |
Chris@0 | 22 * @param string $data |
Chris@0 | 23 * The file or url path to load. |
Chris@0 | 24 */ |
Chris@0 | 25 public function __construct($data, $encoding = 'UTF-8', $debug = '') |
Chris@0 | 26 { |
Chris@0 | 27 // Get the contents of the file. |
Chris@0 | 28 $content = file_get_contents($data); |
Chris@0 | 29 |
Chris@0 | 30 parent::__construct($content, $encoding, $debug); |
Chris@0 | 31 } |
Chris@0 | 32 } |