public function matchesDomain(string $domain): bool
    {
        $cookieDomain = $this->getAttribute(static::ATTR_DOMAIN) ?? '';

        if (0 === strpos($cookieDomain, '.')) {
            $pattern = '/\b'.preg_quote(substr($cookieDomain, 1), '/').'$/i';

            return (bool) preg_match($pattern, $domain);
        } else {
            return 0 == strcasecmp($cookieDomain, $domain);
        }
    }
public function matchesDomain(string $domain): bool
    {
        $cookieDomain = $this->getAttribute(static::ATTR_DOMAIN) ?? '';

        if (0 === strpos($cookieDomain, '.')) {
            $pattern = '/\b'.preg_quote(substr($cookieDomain, 1), '/').'$/i';

            return (bool) preg_match($pattern, $domain);
        } else {
            return 0 == strcasecmp($cookieDomain, $domain);
        }
    }
public function matchesDomain ( string $ domain ) : bool { $ cookieDomain = $ this -> getAttribute ( static :: ATTR_DOMAIN ) ?? '' ; if ( 0 === strpos ( $ cookieDomain , '.' ) ) { $ pattern = '/\b' . preg_quote ( substr ( $ cookieDomain , 1 ) , '/' ) . '$/i' ; return ( bool ) preg_match ( $ pattern , $ domain ) ; } else { return 0 == strcasecmp ( $ cookieDomain , $ domain ) ; } }
Returns true if the current cookie matches the supplied domain.

@param string $domain A domain hostname
Returns true if the current cookie matches the supplied domain .