/**
  * @param string $locale
  * @return Context
  */
 public function build($locale = null)
 {
     $context = Context::of();
     foreach ($this->defaults as $key => $default) {
         $context[$key] = $default;
     }
     if (is_null($locale)) {
         $locale = $context->getLocale();
     }
     $locale = $this->converter->convert($locale);
     $fallbackLanguages = $this->fallbackLanguages;
     $language = \Locale::getPrimaryLanguage($locale);
     $languages = [$language];
     if (isset($fallbackLanguages[$language])) {
         $languages = array_merge($languages, $fallbackLanguages[$language]);
     }
     $context->setLanguages($languages)->setLocale($locale);
     return $context;
 }
 /**
  * @param $locale
  * @param $clientCredentials
  * @param $fallbackLanguages
  * @return static
  */
 public function build($locale, $clientCredentials = null, $fallbackLanguages = null)
 {
     if (is_null($clientCredentials)) {
         $clientCredentials = $this->clientCredentials;
     }
     if (is_null($fallbackLanguages)) {
         $fallbackLanguages = $this->fallbackLanguages;
     }
     $language = \Locale::getPrimaryLanguage($locale);
     $languages = array_merge([$language], $fallbackLanguages[$language]);
     $context = Context::of()->setLanguages($languages)->setGraceful(true)->setLocale($locale);
     if (getenv('SPHERE_CLIENT_ID')) {
         $config = ['client_id' => getenv('SPHERE_CLIENT_ID'), 'client_secret' => getenv('SPHERE_CLIENT_SECRET'), 'project' => getenv('SPHERE_PROJECT')];
     } else {
         $config = $clientCredentials;
     }
     $config = Config::fromArray($config)->setContext($context);
     if (is_null($this->logger)) {
         return Client::ofConfigAndCache($config, $this->cache);
     }
     return Client::ofConfigCacheAndLogger($config, $this->cache, $this->logger);
 }