/framework/vendor/zend/Zend/Pdf/Element/Stream.php
PHP | 117 lines | 35 code | 17 blank | 65 comment | 0 complexity | fed57ba614d7b5a600d5abfcc80aed81 MD5 | raw file
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-2010 Zend Technologies USA Inc. (http://www.zend.com) 18 * @license http://framework.zend.com/license/new-bsd New BSD License 19 * @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $ 20 */ 21 22 23/** Internally used classes */ 24require_once 'Zend/Pdf.php'; 25 26 27/** Zend_Pdf_Element */ 28require_once 'Zend/Pdf/Element.php'; 29 30/** 31 * PDF file 'stream' element implementation 32 * 33 * @category Zend 34 * @package Zend_Pdf 35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 36 * @license http://framework.zend.com/license/new-bsd New BSD License 37 */ 38class Zend_Pdf_Element_Stream extends Zend_Pdf_Element 39{ 40 /** 41 * Object value 42 * 43 * @var Zend_Memory_Container 44 */ 45 public $value; 46 47 48 /** 49 * Object constructor 50 * 51 * @param string $val 52 */ 53 public function __construct($val) 54 { 55 $this->value = Zend_Pdf::getMemoryManager()->create($val); 56 } 57 58 59 /** 60 * Return type of the element. 61 * 62 * @return integer 63 */ 64 public function getType() 65 { 66 return Zend_Pdf_Element::TYPE_STREAM; 67 } 68 69 70 /** 71 * Stream length. 72 * (Method is used to avoid string copying, which may occurs in some cases) 73 * 74 * @return integer 75 */ 76 public function length() 77 { 78 return strlen($this->value->getRef()); 79 } 80 81 82 /** 83 * Clear stream 84 * 85 */ 86 public function clear() 87 { 88 $ref = &$this->value->getRef(); 89 $ref = ''; 90 $this->value->touch(); 91 } 92 93 94 /** 95 * Append value to a stream 96 * 97 * @param mixed $val 98 */ 99 public function append($val) 100 { 101 $ref = &$this->value->getRef(); 102 $ref .= (string)$val; 103 $this->value->touch(); 104 } 105 106 107 /** 108 * Return object as string 109 * 110 * @param Zend_Pdf_Factory $factory 111 * @return string 112 */ 113 public function toString($factory = null) 114 { 115 return "stream\n" . $this->value->getRef() . "\nendstream"; 116 } 117}