Created
January 21, 2017 07:39
-
-
Save shaikhul/2a72e9d5ae1632448b34142eaec11016 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Single Responsiblity Principle client code | |
*/ | |
// create a book instance, book has no knowledge about rendering | |
$book = new Book(); | |
$book->setTitle("Some Title"); | |
$book->setAuthor("Some Author"); | |
// now render it in plain text, specialized in Plain text only! | |
$plain_renderer = new PlainTextRenderer(); | |
echo $plain_renderer->render($book->getCurrentPage()); | |
// and now render in html, specialized in HTML only! | |
$html_renderer = new HTMLRenderer(); | |
echo $html_renderer->render($book->getCurrentPage()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment