<commit_before><?php

if (PHP_SAPI !== 'cli') {
    die('Command line access only' . PHP_EOL);
}

if (!isset($argv[1])) {
    die("Please supply a method to call, like so: php janus_client.php getMetadata https://example.edu" . PHP_EOL);
}
try {
require './../library/EngineBlock/ApplicationSingleton.php';

$application = EngineBlock_ApplicationSingleton::getInstance();
$application->bootstrap();

$config = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration()->serviceRegistry;
$restClient = new Janus_Rest_Client($config->location, $config->user, $config->user_secret);

$client = new Janus_Client();
$client->setRestClient($restClient);
$methodName = $argv[1];
$arguments = array_slice($argv, 2);
$result = call_user_func_array(array($client, $methodName), $arguments);

var_dump($restClient->getHttpClient()->getLastRequest());
var_dump($restClient->getHttpClient()->getLastResponse()->getHeadersAsString());
var_dump($restClient->getHttpClient()->getLastResponse()->getBody());
var_dump($result);
} catch(Exception $e) {
  var_dump($e);
}<commit_msg>Made test client for JANUS more low level, able to handle methods that are not used by EngineBlock<commit_after>#!/usr/bin/php
<?php

if (PHP_SAPI !== 'cli') {
    die('Command line access only' . PHP_EOL);
}

if (!isset($argv[1])) {
    die(
        'Please supply a method to call, format: ./bin/janus_client.php {method name}[ {querystring}]' . PHP_EOL .
        'Example: ./bin/janus_client.php getMetadata "entityid=https://example.edu&keys=certData"' . PHP_EOL
    );
}
try {
require __DIR__ . '/../library/EngineBlock/ApplicationSingleton.php';

$application = EngineBlock_ApplicationSingleton::getInstance();
$application->bootstrap();

$config = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration()->serviceRegistry;
$restClient = new Janus_Rest_Client($config->location, $config->user, $config->user_secret);

$methodName = $argv[1];
$restClient->$methodName();

if (isset($argv[2])) {
    $arguments = array();
    parse_str($argv[2], $arguments);
    foreach ($arguments as $argumentName => $argumentValue) {
        $restClient->$argumentName($argumentValue);
    }
}

$result = $restClient->get();

var_dump($restClient->getHttpClient()->getLastRequest());
var_dump($restClient->getHttpClient()->getLastResponse()->getHeadersAsString());
var_dump($restClient->getHttpClient()->getLastResponse()->getBody());
var_dump($result);
} catch(Exception $e) {
  var_dump($e);
}

{'fraction_non_alphanumeric': 0.17651821862348177, 'fraction_numerical': 0.002834008097165992, 'mean_word_length': 6.354166666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 2, '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': '5245586', 'n_tokens_mistral': 762, 'n_tokens_neox': 755, 'n_words': 142}