-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mikey179
committed
Jul 19, 2016
1 parent
e077c35
commit 1d8f545
Showing
11 changed files
with
201 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* This file is part of stubbles. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package stubbles\streams | ||
*/ | ||
namespace stubbles\streams; | ||
/** | ||
* Abstract base class for decorated input streams. | ||
* | ||
* @api | ||
*/ | ||
abstract class DecoratedInputStream implements InputStream | ||
{ | ||
/** | ||
* input stream to encode into internal encoding | ||
* | ||
* @type \stubbles\streams\InputStream | ||
*/ | ||
protected $inputStream; | ||
|
||
/** | ||
* constructor | ||
* | ||
* @param \stubbles\streams\InputStream $inputStream | ||
*/ | ||
public function __construct(InputStream $inputStream) | ||
{ | ||
$this->inputStream = $inputStream; | ||
} | ||
|
||
/** | ||
* reads given amount of bytes | ||
* | ||
* @param int $length max amount of bytes to read | ||
* @return string | ||
*/ | ||
public function read(int $length = 8192): string | ||
{ | ||
return $this->inputStream->read($length); | ||
} | ||
|
||
/** | ||
* reads given amount of bytes or until next line break | ||
* | ||
* @param int $length max amount of bytes to read | ||
* @return string | ||
*/ | ||
public function readLine(int $length = 8192): string | ||
{ | ||
return $this->inputStream->readLine($length); | ||
} | ||
|
||
/** | ||
* returns the amount of byted left to be read | ||
* | ||
* @return int | ||
*/ | ||
public function bytesLeft(): int | ||
{ | ||
return $this->inputStream->bytesLeft(); | ||
} | ||
|
||
/** | ||
* returns true if the stream pointer is at EOF | ||
* | ||
* @return bool | ||
*/ | ||
public function eof(): bool | ||
{ | ||
return $this->inputStream->eof(); | ||
} | ||
|
||
/** | ||
* closes the stream | ||
*/ | ||
public function close() | ||
{ | ||
$this->inputStream->close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* This file is part of stubbles. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package stubbles\streams | ||
*/ | ||
namespace stubbles\streams; | ||
/** | ||
* Abstract base class for decorated output streams. | ||
* | ||
* @api | ||
*/ | ||
abstract class DecoratedOutputStream implements OutputStream | ||
{ | ||
/** | ||
* input stream to encode into internal encoding | ||
* | ||
* @type \stubbles\streams\OutputStream | ||
*/ | ||
protected $outputStream; | ||
|
||
/** | ||
* constructor | ||
* | ||
* @param \stubbles\streams\OutputStream $outputStream | ||
*/ | ||
public function __construct(OutputStream $outputStream) | ||
{ | ||
$this->outputStream = $outputStream; | ||
} | ||
|
||
/** | ||
* writes given bytes | ||
* | ||
* @param string $bytes | ||
* @return int amount of written bytes | ||
*/ | ||
public function write(string $bytes): int | ||
{ | ||
return $this->outputStream->write($bytes); | ||
} | ||
|
||
/** | ||
* writes given bytes and appends a line break | ||
* | ||
* @param string $bytes | ||
* @return int amount of written bytes excluding line break | ||
*/ | ||
public function writeLine(string $bytes): int | ||
{ | ||
return $this->outputStream->writeLine($bytes); | ||
} | ||
|
||
/** | ||
* writes given bytes and appends a line break after each one | ||
* | ||
* @param string[] $bytes | ||
* @return int amount of written bytes | ||
* @since 3.2.0 | ||
*/ | ||
public function writeLines(array $bytes): int | ||
{ | ||
return $this->outputStream->writeLines($bytes); | ||
} | ||
|
||
/** | ||
* closes the stream | ||
*/ | ||
public function close() | ||
{ | ||
$this->outputStream->close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.