Code Duplication    Length = 3-3 lines in 2 locations

src/Drupal/Driver/Cores/Drupal7.php 1 location

@@ 506-508 (lines=3) @@
503
    // Throw an exception if a bundle is specified but does not exist.
504
    if (isset($entity->$bundle_key) && ($entity->$bundle_key !== NULL)) {
505
      $bundles = $info['bundles'];
506
      if (!in_array($entity->$bundle_key, array_keys($bundles))) {
507
        throw new \Exception("Cannot create entity because provided bundle {$entity->$bundle_key} does not exist.");
508
      }
509
    }
510
    if (empty($entity_type)) {
511
      throw new \Exception("You must specify an entity type to create an entity.");

src/Drupal/Driver/Cores/Drupal8.php 1 location

@@ 502-504 (lines=3) @@
499
      /** @var \Drupal\Core\Entity\EntityTypeBundleInfo $bundle_info */
500
      $bundle_info = \Drupal::service('entity_type.bundle.info');
501
      $bundles = $bundle_info->getBundleInfo($entity_type);
502
      if (!in_array($entity->$bundle_key, array_keys($bundles))) {
503
        throw new \Exception("Cannot create entity because provided bundle '$entity->$bundle_key' does not exist.");
504
      }
505
    }
506
    if (empty($entity_type)) {
507
      throw new \Exception("You must specify an entity type to create an entity.");