<commit_before><?php

if (!defined('SLIM_MODE')) {
    $mode = getenv('SLIM_MODE') ? getenv('SLIM_MODE') : 'production';
    define('SLIM_MODE', $mode);
}

define('APPLICATION_PATH', realpath(dirname(__DIR__)));

require_once APPLICATION_PATH . '/vendor/autoload.php';

use GraphStory\GraphKit\Exception\JsonResponseEncodingException;
use GraphStory\GraphKit\Neo4jClient;
use GraphStory\GraphKit\Service\Content;
use GraphStory\GraphKit\Service\User;
use GraphStory\GraphKit\Slim\JsonResponse;
use GraphStory\GraphKit\Slim\Middleware\Navigation;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Slim\Middleware\SessionCookie;
use Slim\Mustache\Mustache;
use Slim\Slim;
use Zend\Config\Factory as ConfigFactory;

$configPaths = sprintf(
    '%s/config/{,*.}{global,%s,secret}.php',
    APPLICATION_PATH,
    SLIM_MODE
);

$config = ConfigFactory::fromFiles(glob($configPaths, GLOB_BRACE));

$neo4jClient = new \Everyman\Neo4j\Client(
    $config['graphStory']['restHost'],
    $config['graphStory']['restPort']
);

$neo4jClient->getTransport()->setAuth(
    $config['graphStory']['restUsername'],
    $config['graphStory']['restPassword']
);

if ($config['graphStory']['https']) {
    $neo4jClient->useHttps();
}

$app = new Slim($config['slim']);

$app->container->singleton('logger', function () use ($config) {
    $logger = new Logger('slim-skeleton');
    $logger->pushHandler(new StreamHandler(
        $config['logging']['logFile'],
        $config['logging']['logLevel']
    ));

    return $logger;
});

$app->jsonResponse = function () use ($app) {
    return new JsonResponse($app->response);
};

$app->error(function (\Exception $e) use ($app) {
    if ($e instanceof JsonResponseEncodingException) {
        $app->logger->error(<commit_msg>->useHttps() is a method of Everyman\Neo4j\Transport, not Client<commit_after><?php

if (!defined('SLIM_MODE')) {
    $mode = getenv('SLIM_MODE') ? getenv('SLIM_MODE') : 'production';
    define('SLIM_MODE', $mode);
}

define('APPLICATION_PATH', realpath(dirname(__DIR__)));

require_once APPLICATION_PATH . '/vendor/autoload.php';

use GraphStory\GraphKit\Exception\JsonResponseEncodingException;
use GraphStory\GraphKit\Neo4jClient;
use GraphStory\GraphKit\Service\Content;
use GraphStory\GraphKit\Service\User;
use GraphStory\GraphKit\Slim\JsonResponse;
use GraphStory\GraphKit\Slim\Middleware\Navigation;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Slim\Middleware\SessionCookie;
use Slim\Mustache\Mustache;
use Slim\Slim;
use Zend\Config\Factory as ConfigFactory;

$configPaths = sprintf(
    '%s/config/{,*.}{global,%s,secret}.php',
    APPLICATION_PATH,
    SLIM_MODE
);

$config = ConfigFactory::fromFiles(glob($configPaths, GLOB_BRACE));

$neo4jClient = new \Everyman\Neo4j\Client(
    $config['graphStory']['restHost'],
    $config['graphStory']['restPort']
);

$neo4jClient->getTransport()->setAuth(
    $config['graphStory']['restUsername'],
    $config['graphStory']['restPassword']
);

if ($config['graphStory']['https']) {
    $neo4jClient->getTransport()->useHttps();
}

$app = new Slim($config['slim']);

$app->container->singleton('logger', function () use ($config) {
    $logger = new Logger('slim-skeleton');
    $logger->pushHandler(new StreamHandler(
        $config['logging']['logFile'],
        $config['logging']['logLevel']
    ));

    return $logger;
});

$app->jsonResponse = function () use ($app) {
    return new JsonResponse($app->response);
};

$app->error(function (\Exception $e) use ($app) {
    if ($e instanceof JsonResponseEncodingException) {
        $app->logger->error(
{'fraction_non_alphanumeric': 0.17404622667780562, 'fraction_numerical': 0.003063213589529379, 'mean_word_length': 5.483754512635379, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '2799131', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1167, 'n_words': 190}