Site icon Hip-Hop Website Design and Development

How to add Default Level-0 parent and Level-1 class in WordPress Category in li element?

I just want to add a class if li is parent class should be level-0 and if li is the child then level-1 etc. I am using the following loop.

 <?php
    $categories = get_categories();
    foreach($categories as $category) {
       echo '<li class="here-i-want-to-add"><a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
    }
    ?>