title: How to programmatically get content type name in Drupal 8
body: <p>I'm working on Drupal 8. And I want to get content type machine name and label. Here is my code:</p>
  
  <pre><code>$cont_type = node_type_get_types();
  foreach ($cont_type as $key =&gt; $value) {
    $label = $value-&gt;name;
    $machine_name = $key;
  }
  </code></pre>
  
  <p>Here I got an error message : <code>Cannot access protected property Drupal\node\Entity\NodeType::$name</code></p>