PdfNumeric.php 902 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 a numeric PDF object
  12. */
  13. class PdfNumeric extends PdfType
  14. {
  15. /**
  16. * Helper method to create an instance.
  17. *
  18. * @param int|float $value
  19. * @return PdfNumeric
  20. */
  21. public static function create($value)
  22. {
  23. $v = new self();
  24. $v->value = $value + 0;
  25. return $v;
  26. }
  27. /**
  28. * Ensures that the passed value is a PdfNumeric instance.
  29. *
  30. * @param mixed $value
  31. * @return self
  32. * @throws PdfTypeException
  33. */
  34. public static function ensure($value)
  35. {
  36. return PdfType::ensureType(self::class, $value, 'Numeric value expected.');
  37. }
  38. }