How can I check the rewrite slug of current post type listing page

Looking to the problem from a different perspective, I’ve reached to a different solution to it.

I’ve created a function to check the post type instead of checking the slug of the post type.
Actually I was trying to assign different CSS Class to each post type

add_action( 'css_class_per_post_type', 'assign_css_class_to_each_post_type' ); // to be called in the place I want the class name to be displayed (I am using timber as the template engine)

function assign_css_class_to_each_post_type( $context ) {

    $post_type = get_post_type($wp_query->post->ID);
    $cssClass=""; // if no post type, no class is added

    if ($post_type == 'project') {
        $cssClass="projects-listing-cpt";
    } 

    if ($post_type == 'music') {
        $cssClass="musics-listing-cpt";
    }

    echo $cssClass;

}