private function VerifyEntity($Method, $Entity) { $EntityTypes = array_reverse(array_merge([get_class($Entity)], array_values(class_parents($Entity, false)))); foreach ($EntityTypes as $EntityType) { if (isset($this->EntityMaps[$EntityType])) { return $this->EntityMaps[$EntityType]; } } throw new UnmappedEntityException('Call to %s with supplied entity of type %s has not been mapped', $Method, get_class($Entity)); }