Created
May 17, 2018 08:30
-
-
Save HavenShen/f562f2d1c2e8f4f06978227d0c027772 to your computer and use it in GitHub Desktop.
Interface Segregation Principle (ISP)
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 | |
$bird = new Parrot(); | |
$bird->fly(); | |
interface BirdInterface | |
{ | |
public function fly(); | |
} | |
class Parrot implements BirdInterface | |
{ | |
public function fly() | |
{ | |
// ...fly away, Peter! | |
} | |
} | |
class Penguin implements BirdInterface | |
{ | |
// ...don't fly | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment