Skip to content

Instantly share code, notes, and snippets.

@altayalp
Created August 1, 2016 23:48
Show Gist options
  • Save altayalp/7927215fd33697af4a07473943ef1f38 to your computer and use it in GitHub Desktop.
Save altayalp/7927215fd33697af4a07473943ef1f38 to your computer and use it in GitHub Desktop.
ISP (Interface Segregation Principle) good practice
<?php
interface MachineInterface
{
public function open();
public function heatWater();
}
interface CoffeeMachineInterface extends MachineInterface
{
public function makeCoffee();
}
interface TeaMachineInterface extends MachineInterface
{
public function makeTea();
}
class CoffeeMachine implements CoffeeMachineInterface
{
public function open()
{
return 'Machine is opening';
}
public function heatWater()
{
return 'Water is heating';
}
public function makeCoffee()
{
return 'Coffee is making';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment