Skip to content

Commit

Permalink
get rid of abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
mikey179 committed Jul 19, 2016
1 parent e077c35 commit 1d8f545
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 157 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* introduced scalar type hints and strict type checking
* deprecated `stubbles\streams\DecodingInputStream::getCharset()`, use `stubbles\streams\DecodingInputStream::charset()` instead, will be removed with 9.0.0
* deprecated `stubbles\streams\EncodingOutputStream::getCharset()`, use `stubbles\streams\EncodingOutputStream::charset()` instead, will be removed with 9.0.0
* deprecated `stubbles\streams\AbstractDecoratedInputStream`, use `stubbles\streams\DecoratedInputStream` instead, will be removed with 9.0.0
* deprecated `stubbles\streams\AbstractDecoratedOutputStream`, use `stubbles\streams\DecoratedOutputStream` instead, will be removed with 9.0.0


7.0.0 (2016-01-11)
Expand Down
70 changes: 3 additions & 67 deletions src/main/php/AbstractDecoratedInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,73 +13,9 @@
* Abstract base class for decorated input streams.
*
* @api
* @deprecated since 8.0.0, use DecoratedInputStream instead, will be removed with 9.0.0
*/
abstract class AbstractDecoratedInputStream implements InputStream
abstract class AbstractDecoratedInputStream extends DecoratedInputStream
{
/**
* 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();
}
// intentionally empty
}
62 changes: 3 additions & 59 deletions src/main/php/AbstractDecoratedOutputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,9 @@
* Abstract base class for decorated output streams.
*
* @api
* @deprecated since 8.0.0, use DecoratedOutputStream instead, will be removed with 9.0.0
*/
abstract class AbstractDecoratedOutputStream implements OutputStream
abstract class AbstractDecoratedOutputStream extends DecoratedOutputStream
{
/**
* 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();
}
// intentionally empty
}
2 changes: 1 addition & 1 deletion src/main/php/DecodingInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @api
*/
class DecodingInputStream extends AbstractDecoratedInputStream
class DecodingInputStream extends DecoratedInputStream
{
/**
* @type string
Expand Down
85 changes: 85 additions & 0 deletions src/main/php/DecoratedInputStream.php
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();
}
}
77 changes: 77 additions & 0 deletions src/main/php/DecoratedOutputStream.php
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();
}
}
2 changes: 1 addition & 1 deletion src/main/php/EncodingOutputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @api
*/
class EncodingOutputStream extends AbstractDecoratedOutputStream
class EncodingOutputStream extends DecoratedOutputStream
{
/**
* @type string
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/filter/FilteredInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* @package stubbles\streams
*/
namespace stubbles\streams\filter;
use stubbles\streams\AbstractDecoratedInputStream;
use stubbles\streams\DecoratedInputStream;
use stubbles\streams\InputStream;
/**
* Input stream applying a filter on data read before returning to requestor.
*
* @api
*/
class FilteredInputStream extends AbstractDecoratedInputStream
class FilteredInputStream extends DecoratedInputStream
{
/**
* predicate which decides on whether a line is acceptable
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/filter/FilteredOutputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* @package stubbles\streams
*/
namespace stubbles\streams\filter;
use stubbles\streams\AbstractDecoratedOutputStream;
use stubbles\streams\DecoratedOutputStream;
use stubbles\streams\OutputStream;
/**
* Output stream applying a filter on data to write.
*
* @api
*/
class FilteredOutputStream extends AbstractDecoratedOutputStream
class FilteredOutputStream extends DecoratedOutputStream
{
/**
* predicate which decides on whether a line is acceptable
Expand Down
Loading

0 comments on commit 1d8f545

Please sign in to comment.