Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
String.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/FileParserDataSource.php';
25 
36 {
37  /**** Instance Variables ****/
38 
39 
44  protected $_string = '';
45 
46 
47 
48  /**** Public Interface ****/
49 
50 
51  /* Concrete Class Implementation */
52 
60  public function __construct($string)
61  {
62  if (empty($string)) {
63  #require_once 'Zend/Pdf/Exception.php';
64  throw new Zend_Pdf_Exception('String is empty',
66  }
67  $this->_size = strlen($string);
68  $this->_string = $string;
69  }
70 
74  public function __destruct()
75  {
76  $this->_string = '';
77  }
78 
92  public function readBytes($byteCount)
93  {
94  if (($this->_offset + $byteCount) > $this->_size) {
95  #require_once 'Zend/Pdf/Exception.php';
96  throw new Zend_Pdf_Exception("Insufficient data to read $byteCount bytes",
98  }
99  $bytes = substr($this->_string, $this->_offset, $byteCount);
100  $this->_offset += $byteCount;
101  return $bytes;
102  }
103 
111  public function readAllBytes()
112  {
113  return $this->_string;
114  }
115 
116 
117  /* Object Magic Methods */
118 
124  public function __toString()
125  {
126  return "String ($this->_size bytes)";
127  }
128 }
const PARAMETER_VALUE_OUT_OF_RANGE
Definition: Exception.php:89