Executes the plural decision code given the number to decide which
plural version to take.

@param string $domain
@param string $n
@param bool   $fallback set to true to get fallback plural index

@return int
321118
protected function getPluralIndex($domain, $n, $fallback)
    {
        //Not loaded domain or translation, use a fallback
        if (!isset($this->plurals[$domain]) || $fallback === true) {
            return $n == 1 ? 0 : 1;
        }

        if (!isset($this->plurals[$domain]['function'])) {
            $code = self::fixTerseIfs($this->plurals[$domain]['code']);
            $this->plurals[$domain]['function'] = eval("return function (\$n) { $code };");
        }

        if ($this->plurals[$domain]['count'] <= 2) {
            return call_user_func($this->plurals[$domain]['function'], $n) ? 1 : 0;
        }

        return call_user_func($this->plurals[$domain]['function'], $n);
    }
1248495
public function domain($domain = null)
    {
        if (is_null($domain)) {
            return $this->getDomain();
        }

        $this->action['domain'] = $domain;

        return $this;
    }
330159
public function npgettext($context, $original, $plural, $value)
    {
        return $this->dnpgettext($this->domain, $context, $original, $plural, $value);
    }
173659
public function getRule($rule, $domain = null)
    {
        if (is_null($domain)) {
            $domain = $this->domain;
        }

        return $this->app['rule_name']->getRule($rule, $domain);
    }
698921
public static function isDnsError(string $domain): bool
    {
        if (\function_exists('checkdnsrr')) {
            /** @noinspection IfReturnReturnSimplificationInspection */
            $mxFound = \checkdnsrr($domain . '.', 'MX');
            if ($mxFound === true) {
                return false;
            }

            $aFound = \checkdnsrr($domain . '.', 'A');
            /** @noinspection IfReturnReturnSimplificationInspection */
            if ($aFound === true) {
                return false;
            }

            return true;
        }

        throw new \Exception(' Can\'t call checkdnsrr');
    }
1257790
public function domain($domain = null)
    {
        if (func_num_args() === 0) {
            return $this->_data['domain'];
        }
        return $this->_data['domain'] = $domain === null ?  $domain : (string) $domain;
    }
936355
public function findTranslation($domain, $key, $locale, $nullWhenNotFound = false)
    {
        // Get the unit
        try {
            $unit = $this->findByDomainAndKey($domain, $key);
        } catch (NotFoundException $e) {
            if ($nullWhenNotFound) {
                return;
            }
            throw $e;
        }

        // Check translation
        if ($unit && $unit->hasTranslation($locale)) {
            return $unit->getTranslation($locale);
        }

        return;
    }
613031
static public function getSecondDomain($domain=null)
	{
	    $domain = !empty($domain) ? $domain : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null);
	    $n = preg_match('/([^.]*\.)?([^.]*\.)?\w+\.\w+$/', $domain, $matches);
	    return $domain && isset($matches[2]) ? $matches[2] : (isset($matches[1]) ? $matches[1] : '');
	}
1110271
protected function checkForSslRecordChanges($domain, $result)
    {
        if (! $ssl_history = History::where('meta', $domain)->first()) {
            return;
        }

        if ($ssl_history->record['valid'] !== $result['certificates']['information'][0]['valid_now']) {
            if (! $result['certificates']['information'][0]['valid_now']) {
                $this->eye->status()->setSick('ssl_'.$domain);
                return $this->eye->notifier()->alert(new Invalid(['domain' => $domain]));
            }
        }

        if ($ssl_history->record['revoked'] !== $result['certificates']['information'][0]['revoked']) {
            if ($result['certificates']['information'][0]['revoked']) {
                $this->eye->status()->setSick('ssl_'.$domain);
                return $this->eye->notifier()->alert(new Revoked(['domain' => $domain]));
            }
        }

        if ($ssl_history->record['expires_soon'] !== $result['certificates']['information'][0]['expires_soon']) {
            if ($result['certificates']['information'][0]['expires_soon']) {
                $this->eye->status()->setSick('ssl_'.$domain);
                return $this->eye->notifier()->alert(new Expiring(['domain' => $domain,
                                                                   'valid_to' => $result['certificates']['information'][0]['valid_to']]));
            }
        }

        if ($ssl_history->record['grade'] !== $result['results']['grade']) {
            return $this->eye->notifier()->alert(new GradeChange(['domain' => $domain,
                                                                  'old_grade' => $ssl_history->record['grade'],
                                                                  'new_grade' => $result['results']['grade']]));
        }

        $this->eye->status()->setHealthy('ssl_'.$domain);
    }
424868
public function ngettext($singular, $plural, $count) {
		if ($this->reader === null) {
			return $count > 1 ? $plural : $singular;
		}
		return $this->reader->ngettext((string)$singular, (string)$plural, $count);
	}
594664
public function helo($domain)
    {
        if (PEAR::isError($error = $this->put('HELO', $domain))) {
            return $error;
        }
        if (PEAR::isError($error = $this->parseResponse(250))) {
            return $error;
        }

        return true;
    }
990656
function toNumber(str, fallback) {
    if (typeof str === 'number') {
        return str;
    }
    if (REGEXP_NUMBER.test(str)) {
        return Number(str);
    }
    return fallback;
}
1091125
public static function translate_plural($string, Translation $translation = null) {
		if ($translation !== null) {
			$translation = self::get($translation->language, $translation->application_name);
		} else {
			$translation = self::get();
		}

		return $translation->translate_string($string);
	}
1065720
public function npgettext($context, $singular, $plural, $count) {
		if ($this->reader === null) {
			return $count > 1 ? $plural : $singular;
		}
		return $this->reader->npgettext((string)$context, (string)$singular, (string)$plural, $count);
	}
1145515
public static function plural($count, $single, $plural = null)
	{
		if (\is_null($plural)) {
			$plural = $single.'s';
		}
		return $count == 1
			? $single
			: $plural;
	}
1028488
public function rawMsg( $domain, $lang, $key ) {
		$domain = $this->normalizeDomain( $domain );
		$lang = $this->normalizeLang( $lang );

		if ( $lang === 'qqx' ) {
			return "($domain/$key)";
		}

		return $this->accessBlobWithFallback( $domain, $lang, $key );
	}
1027432
public function dnpgettext($domain, $context, $original, $plural, $value)
    {
        $translation = $this->getTranslation($domain, $context, $original);
        $key = $this->getPluralIndex($domain, $value, $translation === false);

        if (isset($translation[$key]) && $translation[$key] !== '') {
            return $translation[$key];
        }

        return ($key === 0) ? $original : $plural;
    }