Boolean.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. /** Zend_Pdf_Element */
  21. require_once 'Zend/Pdf/Element.php';
  22. /**
  23. * PDF file 'boolean' element implementation
  24. *
  25. * @category Zend
  26. * @package Zend_Pdf
  27. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. */
  30. class Zend_Pdf_Element_Boolean extends Zend_Pdf_Element
  31. {
  32. /**
  33. * Object value
  34. *
  35. * @var boolean
  36. */
  37. public $value;
  38. /**
  39. * Object constructor
  40. *
  41. * @param boolean $val
  42. * @throws Zend_Pdf_Exception
  43. */
  44. public function __construct($val)
  45. {
  46. if (! is_bool($val)) {
  47. throw new Zend_Pdf_Exception('Argument must be boolean.');
  48. }
  49. $this->value = $val;
  50. }
  51. /**
  52. * Return type of the element.
  53. *
  54. * @return integer
  55. */
  56. public function getType()
  57. {
  58. return Zend_Pdf_Element::TYPE_BOOL;
  59. }
  60. /**
  61. * Return object as string
  62. *
  63. * @param Zend_Pdf_Factory $factory
  64. * @return string
  65. */
  66. public function toString($factory = null)
  67. {
  68. return $this->value ? 'true' : 'false';
  69. }
  70. }