Larvel paginator

I’m trying to rewrite a paginator that I wrote some time ago, I want to write an Object Oriented version of it.

I’m copying from the laravel framework, I’m looking at their paginator class at https://laravel.com/api/5.6/Illuminate/Contracts/Pagination/Paginator.html I understand most of the code and the methods.
But I don’t understand how the paginator works with other classes…
e.g this is how the paginate method is called: $users = DB::table(‘users’)->paginate(15);

The paginate method is defined in the query Builder class: https://github.com/laravel/framework/blob/5.6/src/Illuminate/Database/Eloquent/Builder.php#L704 , and it returns an instance of the paginator class

What confuses me is that on the above screenshot the paginate method is called on the DB class, since the paginate method is not defined on the DB classs, I would expect the DB class to extend the query Builder class… how is it possible that the paginate method is called on the DB class, and the DB class doesn’t extend the Builder class ?