Code Duplication    Length = 3-3 lines in 2 locations

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

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

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

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