ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
StringReader.php
Go to the documentation of this file.
1<?php
2
3namespace 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}
An exception for terminatinating execution or to throw for unit testing.
seekto($pos)
Move the cursor to a specific position.
read($bytes)
Read and returns a part of the string.
__construct($str)
Constructor.
str(MessageInterface $message)
Returns the string representation of an HTTP message.
Definition: functions.php:18