| 1 | <?php | ||
| 7 | class Stream implements ReaderInterface | ||
| 8 | { | ||
| 9 | /** | ||
| 10 | * @var string $filename The name of the file this stream represents. | ||
| 11 | */ | ||
| 12 | private $filename; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * @var resource $resource The underlying stream this object represents. | ||
| 16 | */ | ||
| 17 | private $resource; | ||
| 18 | |||
| 19 | |||
| 20 | /** | ||
| 21 | * Create a new instance. | ||
| 22 | * | ||
| 23 | * @param string $filename The name of the file this stream represents | ||
| 24 | */ | ||
| 25 | 16 | public function __construct($filename) | |
| 29 | |||
| 30 | |||
| 31 | /** | ||
| 32 | * Read a line from the stream | ||
| 33 | * | ||
| 34 | * @return string | ||
| 35 | */ | ||
| 36 | 8 | public function line() | |
| 40 | |||
| 41 | |||
| 42 | /** | ||
| 43 | * Read from the stream until EOF (^D) is reached | ||
| 44 | * | ||
| 45 | * @return string | ||
| 46 | */ | ||
| 47 | 8 | public function multiLine() | |
| 51 | |||
| 52 | |||
| 53 | /** | ||
| 54 | * Read one character | ||
| 55 | * | ||
| 56 | * @param int $count | ||
| 57 | * | ||
| 58 | * @return string | ||
| 59 | */ | ||
| 60 | 4 | public function char($count = 1) | |
| 64 | |||
| 65 | |||
| 66 | /** | ||
| 67 | * Read the line, but hide what the user is typing | ||
| 68 | * | ||
| 69 | * @return string | ||
| 70 | */ | ||
| 71 | public function hidden() | ||
| 75 | |||
| 76 | |||
| 77 | /** | ||
| 78 | * Return a valid resource, even if it previously EOF'ed. | ||
| 79 | * | ||
| 80 | * @return resource | ||
| 81 | */ | ||
| 82 | 16 | private function getResource() | |
| 99 | } | ||
| 100 |