<commit_before><?php

// Service container configuration

use App\Utility\ErrorHandler;
use Aura\Session\Session;
use Aura\Session\SessionFactory;
use DI\Container;
use League\Plates\Engine;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Odan\Asset\PlatesAssetExtension;
use Odan\Config\ConfigBag;
use Odan\Database\Connection;
use Psr\Log\LoggerInterface;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Router;
use Symfony\Component\Translation\Loader\MoFileLoader;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Translator;

$container = [];

// -----------------------------------------------------------------------------
// Settings
// -----------------------------------------------------------------------------
$container['settings'] = function (Container $container) {
    return $container->get(ConfigBag::class)->export();
};

$container[ConfigBag::class] = function (Container $container) {
    $config = new ConfigBag();
    $config->load(__DIR__ . '/config.php');
    return $config;
};

// -----------------------------------------------------------------------------
// Slim definition aliases
// -----------------------------------------------------------------------------
$container[Request::class] = DI\get('request');
$container[Response::class] = DI\get('response');
$container[Router::class] = DI\get('router');
$container['phpErrorHandler'] = DI\get('errorHandler');

// -----------------------------------------------------------------------------
// Custom aliases
// -----------------------------------------------------------------------------
$container[PDO::class] = DI\get(Connection::class);

// -----------------------------------------------------------------------------
// Slim definitions
// -----------------------------------------------------------------------------

// Handle PHP Exceptions
$container['errorHandler'] = function (Container $container) {
    $displayErrorDetails = $container->get('settings')['displayErrorDetails'];
    $logger = $container->get(LoggerInterface::class);
    return new ErrorHandler((bool)$displayErrorDetails, $logger);
};

// -----------------------------------------------------------------------------
// Custom definitions
// -----------------------------------------------------------------------------
$container[LoggerInterface::class] = function (Container $container) {
    $settings = $container->get('settings');
    $logger = new Logger($settings['logger']['name']);
    
    $level = $settings['logger']['level'];
    if (!isset($level)) {
        $level = Logger::ERROR;
    }
    $logFile = $settings['logger']['file'];
    $handler = new RotatingFileHandler($logFile, 0, $level, true, 0775);
    $logger->pushHandler($handler);

    return $logger;
};

$container[Engine::class] = function (Container $container) {
    $settings = $container->get('settings');
    $engine = new Engine($settings['view']['path'], null);

    // Add folder shortcut (assets::file.js)
    $engine->addFolder('assets', $settings['assets']['path']);
    $engine->addFolder('view', $settings['view']['path']);

    // Register Asset extension
    $engine->loadExtension(new PlatesAssetExtension((array)$settings['assets']));<commit_msg>Updated container<commit_after><?php

// Service container configuration

use App\Utility\ErrorHandler;
use Aura\Session\Session;
use Aura\Session\SessionFactory;
use DI\Container;
use League\Plates\Engine;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Odan\Asset\PlatesAssetExtension;
use Odan\Config\ConfigBag;
use Odan\Database\Connection;
use Psr\Log\LoggerInterface;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Router;
use Symfony\Component\Translation\Loader\MoFileLoader;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Translator;

$container = [];

// -----------------------------------------------------------------------------
// Settings
// -----------------------------------------------------------------------------
$container['settings'] = function (Container $container) {
    return $container->get(ConfigBag::class)->export();
};

$container[ConfigBag::class] = function () {
    $config = new ConfigBag();
    $config->load(__DIR__ . '/config.php');
    return $config;
};

// -----------------------------------------------------------------------------
// Slim definition aliases
// -----------------------------------------------------------------------------
$container[Request::class] = DI\get('request');
$container[Response::class] = DI\get('response');
$container[Router::class] = DI\get('router');
$container['phpErrorHandler'] = DI\get('errorHandler');

// -----------------------------------------------------------------------------
// Custom aliases
// -----------------------------------------------------------------------------
$container[PDO::class] = DI\get(Connection::class);

// -----------------------------------------------------------------------------
// Slim definitions
// -----------------------------------------------------------------------------

// Handle PHP Exceptions
$container['errorHandler'] = function (Container $container) {
    $displayErrorDetails = $container->get('settings')['displayErrorDetails'];
    $logger = $container->get(LoggerInterface::class);
    return new ErrorHandler((bool)$displayErrorDetails, $logger);
};

// -----------------------------------------------------------------------------
// Custom definitions
// -----------------------------------------------------------------------------
$container[LoggerInterface::class] = function (Container $container) {
    $settings = $container->get('settings');
    $logger = new Logger($settings['logger']['name']);

    $level = $settings['logger']['level'];
    if (!isset($level)) {
        $level = Logger::ERROR;
    }
    $logFile = $settings['logger']['file'];
    $handler = new RotatingFileHandler($logFile, 0, $level, true, 0775);
    $logger->pushHandler($handler);

    return $logger;
};

$container[Engine::class] = function (Container $container) {
    $settings = $container->get('settings');
    $engine = new Engine($settings['view']['path'], null);

    // Add folder shortcut (assets::file.js)
    $engine->addFolder('assets', $settings['assets']['path']);
    $engine->addFolder('view', $settings['view']['path']);

    // Register Asset extension
    $engine->loadExtension(new PlatesAssetExtension((array)$settings['assets']));
{'fraction_non_alphanumeric': 0.37162576687116566, 'fraction_numerical': 0.0015337423312883436, 'mean_word_length': 1.7526382439848036, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '5680541', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1469, 'n_words': 280}