/** * OauthStack constructor. * @param array|null $credentials * @throws TwitterStreamingException */ public function __construct(array $credentials = null) { parent::__construct(); try { // Check if Dotenv library is loaded // If credentials are provided, let's prioritize those // values instead of take in consideration the Dotenv library if (class_exists('Dotenv\\Dotenv') && !$credentials) { /** * Load the .env files which must contain * the token of your Twitter Application */ if (file_exists(getcwd() . DIRECTORY_SEPARATOR . '.env')) { (new Dotenv(getcwd()))->load(); } else { (new Dotenv(dirname(getcwd())))->load(); } } else { // If Dotenv library are not loaded, the credentials should // be provided in the constructor of the Tracker if (!is_array($credentials) || !count($credentials)) { throw new TwitterStreamingException(sprintf('TwitterStreaming suggests to use vlucas/phpdotenv ' . 'library to store you Twitter app credentials. ' . 'If you do not want to use it, you should provide those ' . 'values in the Tracker instance. Please take a look the example: ' . '"examples/WithoutDotEnv.php"')); } $this->credentials = $credentials; } } catch (TwitterStreamingException $e) { exit($e->getMessage()); } }
public function __construct() { // Necesary to retrieve the stack (or create the new instance if doesnt exists) parent::__construct(); }