Last active
September 16, 2021 13:15
-
-
Save Vijaysinh/4180d9789c8959144eceda101f6cf4d2 to your computer and use it in GitHub Desktop.
SOLID - InterfaceSegregationPrinciple PHP
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 | |
interface VehicleInterface { | |
public function drive(); | |
public function fly(); | |
} | |
class FutureCar implements VehicleInterface { | |
public function drive() { | |
echo 'Driving a future car!'; | |
} | |
public function fly() { | |
echo 'Flying a future car!'; | |
} | |
} | |
class Car implements VehicleInterface { | |
public function drive() { | |
echo 'Driving a car!'; | |
} | |
public function fly() { | |
throw new Exception('Not implemented method'); | |
} | |
} | |
class Airplane implements VehicleInterface { | |
public function drive() { | |
throw new Exception('Not implemented method'); | |
} | |
public function fly() { | |
echo 'Flying an airplane!'; | |
} | |
} | |
interface CarInterface { | |
public function drive(); | |
} | |
interface AirplaneInterface { | |
public function fly(); | |
} | |
class FutureCar implements CarInterface, AirplaneInterface { | |
public function drive() { | |
echo 'Driving a future car!'; | |
} | |
public function fly() { | |
echo 'Flying a future car!'; | |
} | |
} | |
class Car implements CarInterface { | |
public function drive() { | |
echo 'Driving a car!'; | |
} | |
} | |
class Airplane implements AirplaneInterface { | |
public function fly() { | |
echo 'Flying an airplane!'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment