Code Duplication    Length = 6-6 lines in 2 locations

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

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

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

@@ 435-440 (lines=6) @@
432
    }
433
434
    // Throw an exception if a bundle is specified but does not exist.
435
    if (isset($entity->$bundle_key) && ($entity->$bundle_key !== NULL)) {
436
      $bundles = \Drupal::entityManager()->getBundleInfo($entity_type);
437
      if (!in_array($entity->$bundle_key, array_keys($bundles))) {
438
        throw new \Exception("Cannot create entity because provided bundle '$entity->$bundle_key' does not exist.");
439
      }
440
    }
441
    if (empty($entity_type)) {
442
      throw new \Exception("You must specify an entity type to create an entity.");
443
    }