<commit_before><?php
use Aerys\Host;
use Amp\Redis\Client;
use Amp\Artax\Client as ArtaxClient;
use Auryn\Injector;
use ekinhbayar\GitAmp\Github\Credentials;
use ekinhbayar\GitAmp\Storage\Counter;
use ekinhbayar\GitAmp\Storage\RedisCounter;
use ekinhbayar\GitAmp\Websocket\Handler;
use ekinhbayar\GitAmp\Client\GitAmp;
use function Aerys\root;
use function Aerys\router;
use function Aerys\websocket;

$injector = new Injector;
$injector->alias(Counter::class, RedisCounter::class);

/*
 * todo: make this work and get rid of that line below
 * $injector->define(Credentials::class, [
    ":username" => "YOUR_USERNAME",
    ":password" => "<PASSWORD>",
    ":token"    => "YOUR_TOKEN"
]);
$injector->make(Credentials::class);*/

$creds = new Credentials("YOUR_USERNAME","YOUR_PWD","YOUR_TOKEN");

$injector->define(Handler::class, [
    ":origins" => ["http://localhost:1337"],
    ":audiohub" => new GitAmp(new ArtaxClient(), $creds)
]);

$injector->make(GitAmp::class);

$injector->define(Client::class, [":uri" => "tcp://localhost:6379"]);

$websocket = $injector->make(Handler::class);
<commit_msg>Fixed credentials instance sharing<commit_after><?php
use Aerys\Host;
use Amp\Redis\Client;
use Amp\Artax\Client as ArtaxClient;
use Auryn\Injector;
use ekinhbayar\GitAmp\Github\Credentials;
use ekinhbayar\GitAmp\Storage\Counter;
use ekinhbayar\GitAmp\Storage\RedisCounter;
use ekinhbayar\GitAmp\Websocket\Handler;
use ekinhbayar\GitAmp\Client\GitAmp;
use function Aerys\root;
use function Aerys\router;
use function Aerys\websocket;

$injector = new Injector;
$injector->alias(Counter::class, RedisCounter::class);

/*
 * todo: make this work and get rid of that line below
 * $injector->define(Credentials::class, [
    ":username" => "YOUR_USERNAME",
    ":password" => "<PASSWORD>",
    ":token"    => "<PASSWORD>"
]);
$injector->make(Credentials::class);*/

$creds = new Credentials("YOUR_USERNAME","YOUR_PWD","YOUR_TOKEN");

// @todo find out why the credentials are being instantiated multiple times
$injector->share($creds);

$injector->define(Handler::class, [
    ":origins" => ["http://localhost:1337"],
    ":audiohub" => new GitAmp(new ArtaxClient(), $creds)
]);

$injector->make(GitAmp::class);

$injector->define(Client::class, [":uri" => "tcp://localhost:6379"]);

$websocket = $injector->make(Handler::class);

{'fraction_non_alphanumeric': 0.17253218884120172, 'fraction_numerical': 0.0068669527896995704, 'mean_word_length': 6.0, 'pattern_counts': {'":': 12, '<': 8, '<?xml version=': 0, '>': 33, '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': '5640459', 'n_tokens_mistral': 889, 'n_tokens_neox': 847, 'n_words': 157}