Created
September 10, 2015 17:59
-
-
Save nelsonsar/23a2fbb6f8dfcb639de2 to your computer and use it in GitHub Desktop.
Where traits may be useful
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
<?php | |
interface InputStream | |
{ | |
public function close(); | |
public function read($numberOfBytes); | |
public function skip($numberOfBytes); | |
} | |
interface MarkableStream | |
{ | |
public function mark(); | |
public function reset(); | |
} | |
interface OutputStream | |
{ | |
public function close(); | |
public function write($bytes); | |
} | |
trait Closeable | |
{ | |
public function close() | |
{ | |
fclose($this->fileDescriptor); | |
} | |
} | |
trait Markable | |
{ | |
// implement mark and reset behavior | |
} | |
class FileInputStream implements InputStream, MarkableStream | |
{ | |
use Closeable; | |
use Markable; | |
//Implement here FileInputStream behavior | |
} | |
class FileOutputStream implements OutputStream | |
{ | |
use Closeable; | |
//Implement here FileInputStream behavior | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment