| @@ 10-51 (lines=42) @@ | ||
| 7 | /** |
|
| 8 | * Pdf source from file |
|
| 9 | */ |
|
| 10 | class FileSource implements SourceInterface |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var string |
|
| 14 | */ |
|
| 15 | private $filename; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @var Pages |
|
| 19 | */ |
|
| 20 | private $pages; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @param string $filename |
|
| 24 | * @param Pages $pages |
|
| 25 | */ |
|
| 26 | public function __construct($filename, Pages $pages = null) |
|
| 27 | { |
|
| 28 | $this->filename = $filename; |
|
| 29 | $this->pages = $pages ?: new Pages; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getName() |
|
| 33 | { |
|
| 34 | return $this->filename; |
|
| 35 | } |
|
| 36 | ||
| 37 | public function getContents() |
|
| 38 | { |
|
| 39 | return file_get_contents($this->filename); |
|
| 40 | } |
|
| 41 | ||
| 42 | public function getStreamReader() |
|
| 43 | { |
|
| 44 | return StreamReader::createByFile($this->filename); |
|
| 45 | } |
|
| 46 | ||
| 47 | public function getPages() |
|
| 48 | { |
|
| 49 | return $this->pages; |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 10-51 (lines=42) @@ | ||
| 7 | /** |
|
| 8 | * Pdf source from raw string |
|
| 9 | */ |
|
| 10 | class RawSource implements SourceInterface |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var string |
|
| 14 | */ |
|
| 15 | private $contents; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @var Pages |
|
| 19 | */ |
|
| 20 | private $pages; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @param string $contents |
|
| 24 | * @param Pages $pages |
|
| 25 | */ |
|
| 26 | public function __construct($contents, Pages $pages = null) |
|
| 27 | { |
|
| 28 | $this->contents = $contents; |
|
| 29 | $this->pages = $pages ?: new Pages; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getName() |
|
| 33 | { |
|
| 34 | return "raw-content"; |
|
| 35 | } |
|
| 36 | ||
| 37 | public function getContents() |
|
| 38 | { |
|
| 39 | return $this->contents; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function getStreamReader() |
|
| 43 | { |
|
| 44 | return StreamReader::createByString($this->contents); |
|
| 45 | } |
|
| 46 | ||
| 47 | public function getPages() |
|
| 48 | { |
|
| 49 | return $this->pages; |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||