/**
  * Wrapper around Jeremy Kendall's PHP Domain Parser that parses the
  * domain/url passed to the function and returns the Tld and Valid domain
  * @param $domain
  * @throws \InvalidArgumentException when the tld is not valid
  * @return array returns an associative array with the domain and tld
  */
 private function parse($domain)
 {
     $pslManager = new PublicSuffixListManager();
     $parser = new Parser($pslManager->getList());
     // First check if the suffix is actually valid
     if (!$parser->isSuffixValid($domain)) {
         throw new \InvalidArgumentException("Invalid TLD");
     }
     $components = [];
     $components["tld"] = $parser->getPublicSuffix($domain);
     $components["domain"] = $parser->getRegisterableDomain($domain);
     return $components;
 }