Skip to content

Instantly share code, notes, and snippets.

@eriktorsner
Last active May 24, 2017 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eriktorsner/f135c87ef050994cdca63ca1b7c099b7 to your computer and use it in GitHub Desktop.
Save eriktorsner/f135c87ef050994cdca63ca1b7c099b7 to your computer and use it in GitHub Desktop.
<?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