<commit_before><?php
/**
 * @author @ct-jensschulze <<EMAIL>>
 */

namespace Commercetools\Sunrise\Service;


use Commercetools\Core\Cache\CacheAdapterInterface;
use Commercetools\Core\Client;
use Commercetools\Core\Config;
use Commercetools\Core\Model\Common\Context;
use Psr\Log\LoggerInterface;

class ClientFactory
{
    /**
     * @param $locale
     * @param $clientCredentials
     * @param $fallbackLanguages
     * @param LoggerInterface $logger
     * @param $cache
     * @return Client
     */
    public static function build(
        $locale,
        $clientCredentials,
        $fallbackLanguages,
        $cache,
        LoggerInterface $logger = null
    ) {
        $language = \Locale::getPrimaryLanguage($locale);
        $languages = $fallbackLanguages[$language];
        $context = Context::of()->setLanguages($languages)->setGraceful(true)->setLocale($locale);
        if (isset($_SERVER['SPHERE_CLIENT_ID'])) {
            $config = [
                'client_id' => $_SERVER['SPHERE_CLIENT_ID'],
                'client_secret' => $_SERVER['SPHERE_CLIENT_SECRET'],
                'project' => $_SERVER['SPHERE_PROJECT']
            ];
        } else {
            $config = $clientCredentials;
        }
        $config = Config::fromArray($config)->setContext($context);


        if (is_null($logger)) {
            return Client::ofConfigAndCache($config, $cache);
        }
        return Client::ofConfigCacheAndLogger($config, $cache, $logger);
    }
}<commit_msg>fix travis<commit_after><?php
/**
 * @author @ct-jensschulze <<EMAIL>>
 */

namespace Commercetools\Sunrise\Service;


use Commercetools\Core\Cache\CacheAdapterInterface;
use Commercetools\Core\Client;
use Commercetools\Core\Config;
use Commercetools\Core\Model\Common\Context;
use Psr\Log\LoggerInterface;

class ClientFactory
{
    /**
     * @param $locale
     * @param $clientCredentials
     * @param $fallbackLanguages
     * @param LoggerInterface $logger
     * @param $cache
     * @return Client
     */
    public static function build(
        $locale,
        $clientCredentials,
        $fallbackLanguages,
        $cache,
        LoggerInterface $logger = null
    ) {
        $language = \Locale::getPrimaryLanguage($locale);
        $languages = $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($logger)) {
            return Client::ofConfigAndCache($config, $cache);
        }
        return Client::ofConfigCacheAndLogger($config, $cache, $logger);
    }
}
{'fraction_non_alphanumeric': 0.13449899125756556, 'fraction_numerical': 0.0, 'mean_word_length': 2.6728395061728394, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7563159', 'n_tokens_mistral': 882, 'n_tokens_neox': 890, 'n_words': 143}