Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
<?php
|
|
2 |
/**
|
|
3 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
4 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
5 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
6 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
7 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
8 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
9 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
10 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
11 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
12 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
13 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
14 |
*
|
|
15 |
* This software consists of voluntary contributions made by many individuals
|
|
16 |
* and is licensed under the LGPL. For more information please see
|
|
17 |
* <http://phing.info>.
|
|
18 |
*/
|
|
19 |
|
|
20 |
/**
|
|
21 |
* Dummy class for reading from string of characters.
|
|
22 |
*
|
|
23 |
* @package phing.system.io
|
|
24 |
*/
|
|
25 |
class StringReader extends InputStreamReader |
|
26 |
{
|
|
27 |
|
|
28 |
/**
|
|
29 |
* @var string
|
|
30 |
*/
|
|
31 |
private $string; |
|
32 |
|
|
33 |
/**
|
|
34 |
* @var int
|
|
35 |
*/
|
|
36 |
private $mark = 0; |
|
37 |
|
|
38 |
/**
|
|
39 |
* @var int
|
|
40 |
*/
|
|
41 |
private $currPos = 0; |
|
42 |
|
|
43 |
/**
|
|
44 |
* @param $string
|
|
45 |
*/
|
|
46 | 1 |
public function __construct($string) |
47 |
{
|
|
48 | 1 |
$this->string = $string; |
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
* @param int $n
|
|
53 |
*/
|
|
54 |
public function skip($n) |
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
/**
|
|
59 |
* @param null $len
|
|
60 |
* @return int|string
|
|
61 |
*/
|
|
62 | 1 |
public function read($len = null) |
63 |
{
|
|
64 | 1 |
if ($len === null) { |
65 | 1 |
return $this->string; |
66 |
}
|
|
67 |
|
|
68 |
if ($this->currPos >= strlen($this->string)) { |
|
69 |
return -1; |
|
70 |
}
|
|
71 |
$out = substr($this->string, $this->currPos, $len); |
|
72 |
$this->currPos += $len; |
|
73 |
|
|
74 |
return $out; |
|
75 |
}
|
|
76 |
|
|
77 |
public function mark() |
|
78 |
{
|
|
79 |
$this->mark = $this->currPos; |
|
80 |
}
|
|
81 |
|
|
82 |
public function reset() |
|
83 |
{
|
|
84 |
$this->currPos = $this->mark; |
|
85 |
}
|
|
86 |
|
|
87 |
public function close() |
|
88 |
{
|
|
89 |
}
|
|
90 |
|
|
91 |
public function open() |
|
92 |
{
|
|
93 |
}
|
|
94 |
|
|
95 |
public function ready() |
|
96 |
{
|
|
97 |
}
|
|
98 |
|
|
99 |
/**
|
|
100 |
* @return bool
|
|
101 |
*/
|
|
102 |
public function markSupported() |
|
103 |
{
|
|
104 |
return true; |
|
105 |
}
|
|
106 |
|
|
107 |
/**
|
|
108 |
* @return string
|
|
109 |
*/
|
|
110 |
public function getResource() |
|
111 |
{
|
|
112 |
return '(string) "' . $this->string . '"'; |
|
113 |
}
|
|
114 |
}
|
Read our documentation on viewing source code .