Get the node count by its node type and node status in Drupal 8
This function will give you the count of the node by its status and content type.

Example: if nodeCountState(1,'article'); 

the count of number of nodes in the article content type which is published will be displayed. 

 public function nodeCountState($status, $type) {
    $query = \Drupal::entityQuery('node')
            -&gt;condition('status', $status)
            -&gt;condition('type', $type);
    $result = $query-&gt;count()-&gt;execute();
    return $result;
  }


Hope this help some one :)