/**
  * @param OAuth2Client                              $oAuth2Client          The OAuth 2.0 client service.
  * @param PersistentDataInterface|null              $persistentDataHandler The persistent data handler.
  * @param UrlDetectionInterface|null                $urlHandler            The URL detection handler.
  * @param PseudoRandomStringGeneratorInterface|null $prsg                  The cryptographically secure pseudo-random string generator.
  */
 public function __construct(OAuth2Client $oAuth2Client, PersistentDataInterface $persistentDataHandler = null, UrlDetectionInterface $urlHandler = null, PseudoRandomStringGeneratorInterface $prsg = null)
 {
     $this->oAuth2Client = $oAuth2Client;
     $this->persistentDataHandler = $persistentDataHandler ?: new FacebookSessionPersistentDataHandler();
     $this->urlDetectionHandler = $urlHandler ?: new FacebookUrlDetectionHandler();
     $this->pseudoRandomStringGenerator = PseudoRandomStringGeneratorFactory::createPseudoRandomStringGenerator($prsg);
 }
 /**
  * Instantiates a new Facebook super-class object.
  *
  * @param array $config
  *
  * @throws FacebookSDKException
  */
 public function __construct(array $config = [])
 {
     $config = array_merge(['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], $config);
     if (!$config['app_id']) {
         throw new FacebookSDKException('Required "app_id" key not supplied in config and could not find fallback environment variable "' . static::APP_ID_ENV_NAME . '"');
     }
     if (!$config['app_secret']) {
         throw new FacebookSDKException('Required "app_secret" key not supplied in config and could not find fallback environment variable "' . static::APP_SECRET_ENV_NAME . '"');
     }
     $this->app = new FacebookApp($config['app_id'], $config['app_secret']);
     $this->client = new FacebookClient(HttpClientsFactory::createHttpClient($config['http_client_handler']), $config['enable_beta_mode']);
     $this->pseudoRandomStringGenerator = PseudoRandomStringGeneratorFactory::createPseudoRandomStringGenerator($config['pseudo_random_string_generator']);
     $this->setUrlDetectionHandler($config['url_detection_handler'] ?: new FacebookUrlDetectionHandler());
     $this->persistentDataHandler = PersistentDataFactory::createPersistentDataHandler($config['persistent_data_handler']);
     if (isset($config['default_access_token'])) {
         $this->setDefaultAccessToken($config['default_access_token']);
     }
     // @todo v6: Throw an InvalidArgumentException if "default_graph_version" is not set
     $this->defaultGraphVersion = $config['default_graph_version'];
 }