/**
  * @param string $locale
  * @param Context $context
  * @param Config $config
  * @return Client
  */
 public function build($locale = null, Context $context = null, Config $config = null)
 {
     if (is_null($config)) {
         $config = $this->config;
     }
     if (is_null($context)) {
         $context = $this->contextFactory->build($locale);
     }
     $config->setContext($context);
     if (is_null($this->logger)) {
         $client = Client::ofConfigAndCache($config, $this->cache);
     } else {
         $client = Client::ofConfigCacheAndLogger($config, $this->cache, $this->logger);
     }
     if ($this->profiler instanceof CommercetoolsProfilerExtension) {
         $client->getHttpClient()->addHandler($this->profiler->getProfileMiddleWare());
     }
     return $client;
 }
 /**
  * @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);
 }