Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stk2k/iostream
Input and output stream library
https://github.com/stk2k/iostream
Last synced: 4 days ago
JSON representation
Input and output stream library
- Host: GitHub
- URL: https://github.com/stk2k/iostream
- Owner: stk2k
- License: mit
- Created: 2021-06-24T07:28:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-09T08:05:02.000Z (over 3 years ago)
- Last Synced: 2024-11-08T20:14:23.794Z (about 2 months ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Input and output stream library
=======================[![Latest Version on Packagist](https://img.shields.io/packagist/v/stk2k/iostream.svg?style=flat-square)](https://packagist.org/packages/stk2k/iostream)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://api.travis-ci.com/stk2k/iostream.svg?branch=main)](https://api.travis-ci.com/stk2k/iostream.svg?branch=main)
[![Coverage Status](https://coveralls.io/repos/github/stk2k/iostream/badge.svg?branch=main)](https://coveralls.io/repos/github/stk2k/iostream/badge.svg?branch=main)
[![Code Climate](https://codeclimate.com/github/stk2k/iostream/badges/gpa.svg)](https://codeclimate.com/github/stk2k/iostream)
[![Total Downloads](https://img.shields.io/packagist/dt/stk2k/iostream.svg?style=flat-square)](https://packagist.org/packages/stk2k/iostream)## Description
Input and output stream library
## Demo
### StringInputStream
```php
use stk2k\iostream\string\StringInputStream;// foreach
$sis = new StringInputStream('Hello');
foreach ($sis as $c){
echo $c . '.'; // H.e.l.l.o.
}// read
$sis = new StringInputStream('Hello');
while($c = $sis->read(1)){
echo $c . '.'; // H.e.l.l.o.
}// read line
$sis = new StringInputStream("Foo\nBar\nBaz");
while($line = $sis->readLine()){
echo $line . '.'; // Foo.Bar.Baz.
}// read lines
$sis = new StringInputStream("Foo\nBar\nBaz");
$lines = $sis->readLines();
echo implode('.', $lines); // Foo.Bar.Baz
```### PushBackStringInputStream
```php
use stk2k\iostream\string\PushBackStringInputStream;
use stk2k\xstring\xStringBuffer;$sis = new PushBackStringInputStream(', World!');
$sis->unread(new xStringBuffer('olleH'));
echo $sis->readLine(); // Hello, World!
```### FileInputStream
```php
use stk2k\filesystem\File;
use stk2k\iostream\file\FileInputStream;// foreach
$file = new File('test/_files/b.txt');
$fis = new FileInputStream($file);
foreach ($fis as $c){
echo $c . '.'; // H.e.l.l.o.
}// read
$file = new File('test/_files/b.txt');
$fis = new FileInputStream($file);
while($c = $fis->read(1)){
echo $c . '.'; // H.e.l.l.o.
}// read line
$file = new File('test/_files/c.txt');
$fis = new FileInputStream($file);
while($line = $fis->readLine()){
echo $line . '.'; // Foo.Bar.Baz.
}// read lines
$file = new File('test/_files/c.txt');
$fis = new FileInputStream($file);
$lines = $fis->readLines();
echo implode('.', $lines); // Foo.Bar.Baz
```## Requirement
PHP 7.2 or later
## Installing stk2k/iostream
The recommended way to install stk2k/iostream is through
[Composer](http://getcomposer.org).```bash
composer require stk2k/iostream
```## License
[MIT](https://github.com/stk2k/iostream/blob/master/LICENSE)## Author
[stk2k](https://github.com/stk2k)
## Disclaimer
This software is no warranty.
We are not responsible for any results caused by the use of this software.
Please use the responsibility of the your self.