/** * @param Definition $definition * @param Property $property * @throws InvalidArgumentException */ private function validateAssociation(Definition $definition, Property $property) { if ($property->isAssociated()) { $targetClass = (string) $property->getAssociation()->getTargetClassName(); if (!array_key_exists($targetClass, $this->entityDefinitions)) { throw new InvalidArgumentException(sprintf("Entity class \"%s\" used in association of \"%s\" entity does not have definition.", $targetClass, (string) $definition->getClassName())); } } }
/** * @param Property $property * @param $newElement * @throws RuntimeException */ private function validateAssociatedEntity(Property $property, $newElement) { if (!is_object($newElement) || !$property->getAssociation()->getTargetClassName()->isClassOf($newElement)) { throw new RuntimeException(sprintf("Property \"%s\" expects instanceof \"%s\" as a value.", $property->getName(), (string) $property->getAssociation()->getTargetClassName())); } }