public function save(EntityInterface $entity, array $options = [])
{
// Check entity name
$entityName = $this->entity();
if (!$entity instanceof $entityName) {
throw new \InvalidArgumentException("Provided entity must be instance of " . $entityName . ", instance of " . get_class($entity) . " given.");
}
if ($entity->isNew()) {
$result = $this->insert($entity, $options);
} else {
$result = $this->update($entity, $options);
}
return $result;
}