<commit_before><?php
/**
 * @copyright  Copyright (c) 2016, Net Inventors GmbH
 * @category   Shopware
 * @author     hrombach
 */

namespace NetiFacebookSdk\Service;

use Facebook\Facebook;
use NetiFacebookSdk\NetiFacebookSdk;

class FacebookSdkFactory
{
    /**
     * @var Facebook[]
     */
    private static $sdk;

    /**
     * @param array $params - defaults = [
     *                      'app_id' => getenv(static::APP_ID_ENV_NAME),
     *                      'app_secret' => getenv(static::APP_SECRET_ENV_NAME),
     *                      'default_graph_version' => static::DEFAULT_GRAPH_VERSION,
     *                      'enable_beta_mode' => false,
     *                      'http_client_handler' => null,
     *                      'persistent_data_handler' => null,
     *                      'pseudo_random_string_generator' => null,
     *                      'url_detection_handler' => null,
     *                      ]
     *
     * @return Facebook
     * @throws \Exception
     */
    public function createSdk(array $params)
    {
        $appId = isset($params['app_id']) ? $params['app_id'] : 'noAppId';
        if (!isset(static::$sdk[$appId]) || !(static::$sdk[$appId] instanceof Facebook)) {
            if (!class_exists('\Facebook\Facebook')) {
                require_once __DIR__ . '/../vendor/facebook/graph-sdk/src/Facebook/autoload.php';
            } elseif (
                version_compare(Facebook::VERSION, NetiFacebookSdk::MINIMUM_SDK_VERSION, '<') ||
                version_compare(Facebook::VERSION, NetiFacebookSdk::BREAKING_VERSION, '>=')
            ) {
                throw new \Exception(
                    sprintf(
                        'Facebook SDK is already loaded, but found version %s is incompatible with required minimum version %s.',
                        Facebook::VERSION,
                        NetiFacebookSdk::MINIMUM_SDK_VERSION
                    )
                );
            }

            static::$sdk[$appId] = new Facebook($params);
        }
<commit_msg>Add code annotation<commit_after><?php
/**
 * @copyright  Copyright (c) 2016, Net Inventors GmbH
 * @category   Shopware
 * @author     hrombach
 */

namespace NetiFacebookSdk\Service;

use Facebook\Facebook;
use NetiFacebookSdk\NetiFacebookSdk;

class FacebookSdkFactory
{
    /**
     * @var Facebook[]
     */
    private static $sdk;

    /**
     * @param array $params - defaults = [
     *                      'app_id' => getenv(static::APP_ID_ENV_NAME),
     *                      'app_secret' => getenv(static::APP_SECRET_ENV_NAME),
     *                      'default_graph_version' => static::DEFAULT_GRAPH_VERSION,
     *                      'enable_beta_mode' => false,
     *                      'http_client_handler' => null,
     *                      'persistent_data_handler' => null,
     *                      'pseudo_random_string_generator' => null,
     *                      'url_detection_handler' => null,
     *                      ]
     *
     * @see Facebook::__construct()
     *
     * @return Facebook
     * @throws \Exception
     */
    public function createSdk(array $params)
    {
        $appId = isset($params['app_id']) ? $params['app_id'] : 'noAppId';
        if (!isset(static::$sdk[$appId]) || !(static::$sdk[$appId] instanceof Facebook)) {
            if (!class_exists('\Facebook\Facebook')) {
                require_once __DIR__ . '/../vendor/facebook/graph-sdk/src/Facebook/autoload.php';
            } elseif (
                version_compare(Facebook::VERSION, NetiFacebookSdk::MINIMUM_SDK_VERSION, '<') ||
                version_compare(Facebook::VERSION, NetiFacebookSdk::BREAKING_VERSION, '>=')
            ) {
                throw new \Exception(
                    sprintf(
                        'Facebook SDK is already loaded, but found version %s is incompatible with required minimum version %s.',
                        Facebook::VERSION,
                        NetiFacebookSdk::MINIMUM_SDK_VERSION
                    )
                );
            }

            static::$sdk[$appId] = new Facebook($params);
        }

{'fraction_non_alphanumeric': 0.11967252588490249, 'fraction_numerical': 0.001926318324103058, 'mean_word_length': 1.6991552956465237, 'pattern_counts': {'":': 0, '<': 7, '<?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': 41, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2337047', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1119, 'n_words': 198}