Code Duplication    Length = 6-6 lines in 2 locations

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

@@ 504-509 (lines=6) @@
501
    }
502
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.");
512
    }

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

@@ 488-493 (lines=6) @@
485
    }
486
487
    // Throw an exception if a bundle is specified but does not exist.
488
    if (isset($entity->$bundle_key) && ($entity->$bundle_key !== NULL)) {
489
      $bundles = \Drupal::entityManager()->getBundleInfo($entity_type);
490
      if (!in_array($entity->$bundle_key, array_keys($bundles))) {
491
        throw new \Exception("Cannot create entity because provided bundle '$entity->$bundle_key' does not exist.");
492
      }
493
    }
494
    if (empty($entity_type)) {
495
      throw new \Exception("You must specify an entity type to create an entity.");
496
    }