Get domain from a URL field
I found the solution to my problem: 

$field_source = $entity-&gt;get('field_source')-&gt;getValue();
$url_link = $field_source[0]['uri'];
$parse = parse_url($url_link);
$value = $parse['host'];