Skip to content

Instantly share code, notes, and snippets.

@Petah
Created September 24, 2012 19:01
Show Gist options
  • Save Petah/3777649 to your computer and use it in GitHub Desktop.
Save Petah/3777649 to your computer and use it in GitHub Desktop.
Counter
class Counter {
private $counter = 0;
public function getCounter()
{
return $this->counter;
}
public function incrementCounter()
{
$this->counter++;
}
}
class GlobalCounter {
public static $counter;
public function __callStatic($name, $args)
{
return call_user_func_array(array(self::$counter, $name), $args);
}
}
GlobalCounter::$counter = new Counter();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment