Doctrine 2 and the law of demeter

Tags:

Doctrine 2 makes it very convenient to access related objects in your code: Just do a $entity->getRelatedSomething()->getThingValue(); However, this kind of pattern makes for easy errors when getRelatedSomething returns null – and as a side effect of this, you can end up with a lot of code which checks if the value exists before accessing it. This in turn can …