Finds the Language model based on its code value.
If the model is not found, a 404 HTTP exception will be thrown.

@param string $code

@return Language the loaded model
@throws NotFoundHttpException if the model cannot be found
329790
protected function findLanguage($code) {
        $language = Language::findOne($code);
        if ($language === null) {
            throw new \yii\web\NotFoundHttpException('The requested language does not exist');
        }
        return $language;
    }
1037474
public function postManage($code = null)
    {
        if ($code === null) {
            throw new NotFoundHttpException();
        }

        $subscriber = Subscriber::where('verify_code', '=', $code)->first();

        if (!$subscriber) {
            throw new BadRequestHttpException();
        }

        try {
            execute(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions')));
        } catch (ValidationException $e) {
            return cachet_redirect('subscribe.manage', $subscriber->verify_code)
                ->withInput(Binput::all())
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
                ->withErrors($e->getMessageBag());
        }

        return cachet_redirect('subscribe.manage', $subscriber->verify_code)
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.updated-subscribe')));
    }
1081765
public function getKeyword($languageCode = null)
    {
        if ($languageCode === null) {
            $languageCode = $this->mainLanguageCode;
        }

        if (isset($this->keywords[$languageCode])) {
            return $this->keywords[$languageCode];
        }

        return null;
    }
978018
public function getReceptionCode($code)
    {
        static $codes = array();

        if (! isset($codes[$code])) {
            $codes[$code] = $this->_loadClass('receptionCode', true, array($code));
        }

        return $codes[$code];
    }
138165
private static function parseRegion($code)
    {
        $lang = substr($code, 0, 2);
        $reg =  strtoupper(substr($code, 3, 2));
        $needle = "{$lang}-{$reg}";
        foreach (self::codes() as $code) {
            if ($code['code'] == $needle) {
                return [$reg, $code['description']];
            }
        }

        throw new UnknownLanguageCodeException(
            "The region code '{$code}'' is unknown."
        );
    }
197466
public function getOne($languageCode, $locale = 'en')
	{

		$result = $this->has($languageCode, $locale);

		if (!$result)
		{
			throw new LanguageNotFoundException($languageCode);
		}

		return $result;
	}
1292702
public static function getPhrase(int $code):string
    {
        if (isset(self::$response[$code])) {
            return (self::$response[$code]);
        } else {
            throw new Server500(new \ArrayObject(array("explain" => "Http code does not exist",
                "solution" => "Please check your http code")));
        }
    }
1330363
public function getLanguageByString(
        $code,
        $format = 'iso639_2t',
        $default = null
    ) {
        if (empty($code)) {
            return $default;
        }

        if (!in_array($format, $this->validFormats)) {
            throw new LanguageNotFoundException('Language Format not valid.');
        }

        try {
            $result = $this->findOneBy([$format => $code]);
        } catch (NoResultException $e) {
            $result = $default;
        }

        return $result;
    }
769832
public function getUrl($languageCode = null)
    {
        if ($languageCode && in_array($languageCode, Language::getAllowedLanguages())) {
            return $this->url . '&lang=' . $languageCode;
        }

        return $this->url;
    }
213622
public static function create($code)
    {
        $class = __NAMESPACE__ . '\Locale\Locale' . implode(array_map(function ($x) {
            return ucfirst(strtolower($x));
        }, preg_split('/[^a-zA-Z0-9]+/', $code)));

        if (class_exists($class)) {
            return new $class();
        }

        throw new DomainException($code);
    }
1343239
public static function get($code)
    {
        try {
            return static::getByAlpha2($code);
        } catch (OutOfBoundsException $e) {
            try {
                return static::getByAlpha3($code);
            } catch (OutOfBoundsException $e) {
                try {
                    return static::getByNumeric3($code);
                } catch (OutOfBoundsException $e) {
                    throw new OutOfBoundsException("The code \"{$code}\" is not listed in ISO 4217");
                }
            }
        }
    }
1259848
public function getPath($languageCode)
    {
        $route = $this->routes()->newQuery()
            ->where('language_code', $languageCode)
            ->first();
        if (empty($route->path)) {
            throw new DomainException("There is no route in '$languageCode' language for content: $this->id");
        }
        return $route->path;
    }
1093817
public function loadByLanguageCode($languageCode)
    {
        $language = $this->cache->get('ez-language-code-' . $languageCode);
        if ($language === null) {
            $language = $this->innerHandler->loadByLanguageCode($languageCode);
            $this->storeCache([$language]);
        }

        return $language;
    }
1146191
public function findOneByCode($code, $deepMode = false)
    {
        //the query builder
        $page = $this->createQueryBuilder($this->mainAlias)
            ->where($this->mainAlias.'.code = :code')
            ->setParameter('code', $code)
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult();

        if (!$page && $deepMode) {
            // Check for a same family error
            // for example, for a 404 code, if the 404 error page doesn't exist, we check for a 400 errorPage
            $page = $this->findOneByCode(floor($code / 100) * 100);
        }

        return $page;
    }
1188498
final public function get($code = null) {

        if ( is_null($code) ) return $this->rpc_errors;

        else if ( array_key_exists($code, $this->rpc_errors) ) return $this->rpc_errors[$code];

        else if ( $code >= -32099 && $code <= -32000 ) return 'Server Error';

        else return 'Unknown Error';

    }
1190035
protected function getVerificationCode($code)
    {
        // Trim Code:
        
        $code = trim($code);
        
        // Detect HTML:
        
        if (stripos($code, '<meta') === 0) {
            
            // Extract Verification Code:
            
            preg_match('/content="(.+)"/', $code, $matches);
            
            // Update or Nullify:
            
            $code = isset($matches[1]) ? $matches[1] : null;
            
        }
        
        // Answer Code:
        
        return $code;
    }
732260
public function create($languageCode) {
    $mappings = $this->getMappings();

    if (!isset($mappings[$languageCode])) {
      throw new \InvalidArgumentException('The language code is not part of the supported list. Please see GoogleSupportedLanguages\LanguageFactory::getMappings() for reference.');
    }

    return new $mappings[$languageCode]();
  }