Skip to content

Instantly share code, notes, and snippets.

@ftdebugger
Created November 15, 2013 14:51
Show Gist options
  • Save ftdebugger/7485511 to your computer and use it in GitHub Desktop.
Save ftdebugger/7485511 to your computer and use it in GitHub Desktop.
<?php
class Lamp
{
public function turnOn()
{
echo "I'm bright and cheerful light.\n";
}
public function turnOff()
{
echo "I am quiet and peaceful shadow\n";
}
}
$lamp = new Lamp();
if ($argv[1] == 'ON') {
$lamp->turnOn();
} else {
if ($argv[1] == 'OFF') {
$lamp->turnOff();
} else {
throw new \RuntimeException('I understand only ON/OFF command');
}
}
@xeoncross
Copy link

if(method_exists($lamp, $argv[1])) { ... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment