Skip to content

Instantly share code, notes, and snippets.

@vahid-almasi
Last active July 17, 2019 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vahid-almasi/4d7ad830ce06aa26db24b8aeb2a8d4a1 to your computer and use it in GitHub Desktop.
Save vahid-almasi/4d7ad830ce06aa26db24b8aeb2a8d4a1 to your computer and use it in GitHub Desktop.
<?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.');
}
}
<?php
interface BookInterface {
public function open();
public function turnPage();
}
<?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