/**
  * @dataProvider domainCheckCases()
  */
 public function testDomainCheck($domain, $expected, $note)
 {
     $this->assertEquals($expected, jabber_check_domain($domain), $note);
 }
Example #2
0
/**
 * Checks whether a string is a syntactically valid base Jabber ID (JID).
 * A base JID won't include a resource specifier on the end; since we
 * take it off when reading input we can't really use them reliably
 * to direct outgoing messages yet (sorry guys!)
 * 
 * Note that a bare domain can be a valid JID.
 * 
 * @param string $jid string to check
 * @param bool $check_domain whether we should validate that domain...
 *
 * @return     boolean whether the string is a valid JID
 */
function jabber_valid_base_jid($jid, $check_domain = false)
{
    try {
        $parts = jabber_split_jid($jid);
        if ($check_domain) {
            if (!jabber_check_domain($parts['domain'])) {
                return false;
            }
        }
        return $parts['resource'] === null;
        // missing; empty ain't kosher
    } catch (Exception $e) {
        return false;
    }
}