Created
May 24, 2017 10:04
-
-
Save eriktorsner/a50347afc2bb53d1869591b978132c54 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 | |
// Solution 1. Let ElectricCar handle unplugging itself | |
class ElectricCar extends Car | |
{ | |
... | |
public function start() | |
{ | |
$this->unplug(); | |
parent::start(); | |
} | |
... | |
} | |
// Solution 2. Change the interface | |
class Car | |
{ | |
public function BeforeStart() | |
{ | |
} | |
public function start() | |
{ | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment