<commit_before><?php namespace Ovide\Libs\Mvc\Rest;

use Phalcon\Mvc\Micro\Collection;
use Phalcon\Mvc\Micro;
use Phalcon\DI\FactoryDefault;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
class App extends Micro
{
    /**
     * @var App Singleton instance
     */
    private static $app;

    /**
     * Configuration sets for HeaderHandlers
     * @var Array
     */
    private $_config = [];

    /**
     * Constructs the app.
     *
     * Checks singleton instance
     * Adds a dependency injector if none provided
     * Sets the notFound handler
     *
     * @param  FactoryDefault    $dependencyInjector
     * @throws \RuntimeException
     */
    public function __construct($dependencyInjector = null)
    {
        if (self::$app === null) {
            if ($dependencyInjector === null) {
                $dependencyInjector = new FactoryDefault();
            }
            $dependencyInjector->setShared('response', function () {
                return new Response();
            });
            parent::__construct($dependencyInjector);
            self::$app = $this;
            $app = self::$app;

            $app->_notFoundHandler = function () use ($app) {
                $app->response->notFound();

                return $app->response;
            };
        } else {
            throw new \RuntimeException("Can't instance RestApp more than once");
        }
    }

    /**
     * Sets a config value for a set-key pair
     *
     * @param string $set
     * @param mixed  $key
     * @param mixed  $value
     */
    public function setConfig($set, $key, $value)
    {
        $this->_config[$set][$key] = $value;
    }

    /**
     * Returns the config value for a set-key pair<commit_msg>Response injection set with classname<commit_after><?php namespace Ovide\Libs\Mvc\Rest;

use Phalcon\Mvc\Micro\Collection;
use Phalcon\Mvc\Micro;
use Phalcon\DI\FactoryDefault;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
class App extends Micro
{
    /**
     * @var App Singleton instance
     */
    private static $app;

    /**
     * Configuration sets for HeaderHandlers
     * @var Array
     */
    private $_config = [];

    /**
     * Constructs the app.
     *
     * Checks singleton instance
     * Adds a dependency injector if none provided
     * Sets the notFound handler
     *
     * @param  FactoryDefault    $dependencyInjector
     * @throws \RuntimeException
     */
    public function __construct($dependencyInjector = null)
    {
        if (self::$app === null) {
            if ($dependencyInjector === null) {
                $dependencyInjector = new FactoryDefault();
            }
            $dependencyInjector->setShared('response', Response::class);
            parent::__construct($dependencyInjector);
            self::$app = $this;
            $app = self::$app;

            $app->_notFoundHandler = function () use ($app) {
                $app->response->notFound();

                return $app->response;
            };
        } else {
            throw new \RuntimeException("Can't instance App more than once");
        }
    }

    /**
     * Sets a config value for a set-key pair
     *
     * @param string $set
     * @param mixed  $key
     * @param mixed  $value
     */
    public function setConfig($set, $key, $value)
    {
        $this->_config[$set][$key] = $value;
    }

    /**
     * Returns the config value for a set-key pair
{'fraction_non_alphanumeric': 0.1234966265767087, 'fraction_numerical': 0.0, 'mean_word_length': 1.902127659574468, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '4838456', 'n_tokens_mistral': 974, 'n_tokens_neox': 960, 'n_words': 248}