Last active
July 17, 2019 19:37
-
-
Save vahid-almasi/4d7ad830ce06aa26db24b8aeb2a8d4a1 to your computer and use it in GitHub Desktop.
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 | |
class Book implements BookInterface { | |
public function open() | |
{ | |
var_dump('opening the paper book.'); | |
} | |
public function turnPage() | |
{ | |
var_dump('turning the page of the paper book.'); | |
} | |
} |
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 BookInterface { | |
public function open(); | |
public function turnPage(); | |
} |
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 | |
class Person { | |
public function read(BookInterface $book) | |
{ | |
$book->open(); | |
$book->turnPage(); | |
} | |
} | |
(new Person)->read(new Book); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment