Drupal 8 Delete all content by code

// Define entity type to lookup.
$entity_type = 'node';

// Execute a query in order to retrieve an array of Article's ids.
$ids = \Drupal::entityQuery($entity_type)
  ->condition('type', 'article')
  ->execute();

/** @var \Drupal\node\NodeStorage $controller */
$controller = \Drupal::entityTypeManager()
  ->getStorage($entity_type);

/** @var \Drupal\node\Entity\Node[] $entities */
$entities = $controller->loadMultiple($ids);

// Deletes permanently saved entities.
$controller->delete($entities);