Last active
May 24, 2017 09:37
-
-
Save eriktorsner/f135c87ef050994cdca63ca1b7c099b7 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 | |
class Car | |
{ | |
public function start() | |
{ | |
/// wrooom | |
} | |
} | |
class ElectricCar extends Car | |
{ | |
private $plugged = true; | |
public function unplug() | |
{ | |
$this->plugged = false; | |
} | |
// Will break clients | |
public function start() | |
{ | |
if ($this->plugged) { | |
throw new Exception('AAarrrg! Car is plugged in, please unplug first'); | |
} | |
parent::start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment