PdfIndirectObjectReference.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * This file is part of FPDI
  4. *
  5. * @package Fpdi
  6. * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
  7. * @license http://opensource.org/licenses/mit-license The MIT License
  8. */
  9. namespace Fpdi\PdfParser\Type;
  10. /**
  11. * Class representing an indirect object reference
  12. */
  13. class PdfIndirectObjectReference extends PdfType
  14. {
  15. /**
  16. * Helper method to create an instance.
  17. *
  18. * @param int $objectNumber
  19. * @param int $generationNumber
  20. * @return self
  21. */
  22. public static function create($objectNumber, $generationNumber)
  23. {
  24. $v = new self();
  25. $v->value = (int) $objectNumber;
  26. $v->generationNumber = (int) $generationNumber;
  27. return $v;
  28. }
  29. /**
  30. * Ensures that the passed value is a PdfIndirectObject instance.
  31. *
  32. * @param mixed $value
  33. * @return self
  34. * @throws PdfTypeException
  35. */
  36. public static function ensure($value)
  37. {
  38. return PdfType::ensureType(self::class, $value, 'Indirect reference value expected.');
  39. }
  40. /**
  41. * The generation number.
  42. *
  43. * @var int
  44. */
  45. public $generationNumber;
  46. }