Best practice: content types with unique machine names
Counting content types should be as easy as:

$result = db_select('node_type')
        -&gt;fields('node_type')
        -&gt;execute();
$num_of_results = $result-&gt;rowCount();


https://www.drupal.org/node/1226410