diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:45:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:45:49 +0000 |
commit | 0ff39c83d38ce538a9f5dba53eca0fa9cb16d9e6 (patch) | |
tree | 84c735df2e97350a721273e9dd425729d43cc8a2 /vendor/iio/libmergepdf/src/Source | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-pdfexport-0ff39c83d38ce538a9f5dba53eca0fa9cb16d9e6.tar.xz icingaweb2-module-pdfexport-0ff39c83d38ce538a9f5dba53eca0fa9cb16d9e6.zip |
Adding upstream version 0.10.2+dfsg1.upstream/0.10.2+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/iio/libmergepdf/src/Source')
-rw-r--r-- | vendor/iio/libmergepdf/src/Source/FileSource.php | 50 | ||||
-rw-r--r-- | vendor/iio/libmergepdf/src/Source/RawSource.php | 45 | ||||
-rw-r--r-- | vendor/iio/libmergepdf/src/Source/SourceInterface.php | 25 |
3 files changed, 120 insertions, 0 deletions
diff --git a/vendor/iio/libmergepdf/src/Source/FileSource.php b/vendor/iio/libmergepdf/src/Source/FileSource.php new file mode 100644 index 0000000..2802d80 --- /dev/null +++ b/vendor/iio/libmergepdf/src/Source/FileSource.php @@ -0,0 +1,50 @@ +<?php + +declare(strict_types = 1); + +namespace iio\libmergepdf\Source; + +use iio\libmergepdf\PagesInterface; +use iio\libmergepdf\Pages; +use iio\libmergepdf\Exception; + +/** + * Pdf source from file + */ +final class FileSource implements SourceInterface +{ + /** + * @var string + */ + private $filename; + + /** + * @var PagesInterface + */ + private $pages; + + public function __construct(string $filename, PagesInterface $pages = null) + { + if (!is_file($filename) || !is_readable($filename)) { + throw new Exception("Invalid file '$filename'"); + } + + $this->filename = $filename; + $this->pages = $pages ?: new Pages; + } + + public function getName(): string + { + return $this->filename; + } + + public function getContents(): string + { + return (string)file_get_contents($this->filename); + } + + public function getPages(): PagesInterface + { + return $this->pages; + } +} diff --git a/vendor/iio/libmergepdf/src/Source/RawSource.php b/vendor/iio/libmergepdf/src/Source/RawSource.php new file mode 100644 index 0000000..7966918 --- /dev/null +++ b/vendor/iio/libmergepdf/src/Source/RawSource.php @@ -0,0 +1,45 @@ +<?php + +declare(strict_types = 1); + +namespace iio\libmergepdf\Source; + +use iio\libmergepdf\PagesInterface; +use iio\libmergepdf\Pages; + +/** + * Pdf source from raw string + */ +final class RawSource implements SourceInterface +{ + /** + * @var string + */ + private $contents; + + /** + * @var PagesInterface + */ + private $pages; + + public function __construct(string $contents, PagesInterface $pages = null) + { + $this->contents = $contents; + $this->pages = $pages ?: new Pages; + } + + public function getName(): string + { + return "raw-content"; + } + + public function getContents(): string + { + return $this->contents; + } + + public function getPages(): PagesInterface + { + return $this->pages; + } +} diff --git a/vendor/iio/libmergepdf/src/Source/SourceInterface.php b/vendor/iio/libmergepdf/src/Source/SourceInterface.php new file mode 100644 index 0000000..4ce9c3c --- /dev/null +++ b/vendor/iio/libmergepdf/src/Source/SourceInterface.php @@ -0,0 +1,25 @@ +<?php + +declare(strict_types = 1); + +namespace iio\libmergepdf\Source; + +use iio\libmergepdf\PagesInterface; + +interface SourceInterface +{ + /** + * Get name of file or source + */ + public function getName(): string; + + /** + * Get pdf content + */ + public function getContents(): string; + + /** + * Get pages to fetch from source + */ + public function getPages(): PagesInterface; +} |