domain() public method

Get the domain name and include $tldLength segments of the tld.
public domain ( integer $tldLength = 1 ) : string
$tldLength integer Number of segments your tld contains. For example: `example.com` contains 1 tld. While `example.co.uk` contains 2.
return string Domain name without subdomains.
 /**
  * Test domain retrieval.
  *
  * @return void
  */
 public function testDomain()
 {
     $_SERVER['HTTP_HOST'] = 'something.example.com';
     $request = new CakeRequest('some/path');
     $this->assertEquals('example.com', $request->domain());
     $_SERVER['HTTP_HOST'] = 'something.example.co.uk';
     $this->assertEquals('example.co.uk', $request->domain(2));
 }
 /**
 * Get domain name
 *
 * @return string
 */
 protected function _getDomain()
 {
     return $this->Request->domain(self::$_tldLength);
 }