Skip to content

Instantly share code, notes, and snippets.

@tarunama
Created September 30, 2014 22:51
Show Gist options
  • Save tarunama/3e23826cd4b678de559c to your computer and use it in GitHub Desktop.
Save tarunama/3e23826cd4b678de559c to your computer and use it in GitHub Desktop.
<?php
abstract class Working
{
abstract protected function where();
abstract protected function why();
abstract protected function how();
public function work()
{
echo $this->where($where);
echo $this->why($reason);
echo $this->how($how);
}
}
class Person extends Working
{
protected function where()
{
return '横浜で';
}
protected function why()
{
return 'お金欲しいから';
}
protected function how()
{
return '営業する';
}
}
$bob = new Person();
$bob->work(); // 横浜でお金欲しいから営業する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment