/** * @param FamilyInterface $family * @param AttributeInterface $attribute * @return bool */ protected function isAttributeInherited(FamilyInterface $family, AttributeInterface $attribute) { if (!$family->getParent()) { return false; } if ($family->getParent()->hasAttribute($attribute->getCode())) { return true; } return $this->isAttributeInherited($family->getParent(), $attribute); }
/** * @param FamilyInterface $child * @throws UnexpectedValueException */ public function addChild(FamilyInterface $child) { if ($child->getParent() && $child->getParent()->getCode() === $this->getCode()) { $this->children[$child->getCode()] = $child; } else { throw new UnexpectedValueException("Child must have it's parent set to the current family"); } }