class ForumThread
{
/**
* @return bool
*/
public function findBadLanguage ($inWhat)
{
return (bool)rand(0,1);
}
/**
* @return
*/
public function add ($threadName)
{
if (!$this->findBadLanguage ($threadName))
{
INSERT INTO
}
}
}
class ForumPost
{
/**
* @return
*/
public function post ($toThreadId, $comment)
{
// im talking about this:
Services::getForumThread()->findBadLanguage($comment);
}
}
我知道findBadLanguage()
应该在另一个班级,但让我们假设没关系。让我们专注于 Services::get****() 调用。转向全局容器并从中获取对象可以吗?还是转厂?它不会加速得墨忒耳定律吗?它说我们不能使用来自外部的物体