Drupal 8 \Drupal calls should be avoided in classes, use | | dependency injection instead
You can check how the dependency injection works in general in this documentation.
https://www.drupal.org/docs/8/api/services-and-dependency-injection/dependency-injection-for-a-form

The parts that you need are:

Use statement - 

 use Symfony\Component\DependencyInjection\ContainerInterface;


Class property - here we are going to store the whole \Drupal::service('current_user') object.

 protected $account;


The __construct magic method. This is called upon instantiating the class.
The dependency injection bit here is providing all the data required in a later stage as input. 

function __construct(AccountInterface $account) {


Built in method that  has a dependency injection
create(ContainerInterface $container)

return new static(
  // Load the service required to construct this class.
  $container-&gt;get('current_user')
);


Eventually we are using the whole construction like that:

$uid = $this-&gt;account-&gt;id();


where $this-&gt;account is the same like \Drupal::service('current_user');