Cat.php
<?php
class Cat
{
protected $name;
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}
app.php
<?php
/**
* 吾輩は猫である
*
* @author Souseki Natsume
* @author Keisuke SATO <riaf@me.com>
*/
// 吾輩は猫である
$me = new Cat;
// 名前はまだ無い
if (!$me->getName()) {
throw new Exception('undefined name');
}