ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
StringReader.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Gettext\Utils;
4 
6 {
7  public $pos;
8  public $str;
9  public $strlen;
10 
16  public function __construct($str)
17  {
18  $this->str = $str;
19  $this->strlen = strlen($this->str);
20  }
21 
29  public function read($bytes)
30  {
31  $data = substr($this->str, $this->pos, $bytes);
32 
33  $this->seekto($this->pos + $bytes);
34 
35  return $data;
36  }
37 
45  public function seekto($pos)
46  {
47  $this->pos = ($this->strlen < $pos) ? $this->strlen : $pos;
48 
49  return $this->pos;
50  }
51 }
seekto($pos)
Move the cursor to a specific position.
__construct($str)
Constructor.
read($bytes)
Read and returns a part of the string.
str(MessageInterface $message)
Returns the string representation of an HTTP message.
Definition: functions.php:18
$data
Definition: bench.php:6