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);
}
}
I know findBadLanguage()
should be in another class, but lets suppose thats okay. Lets focus on Services::get****() calls. Is it OK to turn to a global container and get objects from it? Or to turn to a factory? Doesnt it hury Demeter's law? It says we must not use object from the outside