<commit_before><?php

declare(strict_types=1);

/*
 * This file is part of eelly package.
 *
 * (c) eelly.com
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Shadon\Di;

use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\WebProcessor;
use Phalcon\Di\Service;
use Shadon\Dispatcher\ServiceDispatcher;
use Shadon\Http\PhalconServiceResponse as ServiceResponse;
use Shadon\Http\ServiceRequest;
use Shadon\Logger\Handler\EellyapiHandler;
use Shadon\Logger\Handler\ServiceHandler;
use Shadon\Mvc\Collection\Manager as CollectionManager;
use Shadon\Mvc\Model\Manager as ModelsManager;
use Shadon\Mvc\Model\Transaction\Manager as TransactionManager;
use Shadon\Router\ServiceRouter;

/**
 * @author hehui<<EMAIL>>
 */
class ServiceDi extends FactoryDefault
{
    public function __construct()
    {
        parent::__construct();
        $this->_services['collectionManager'] = new Service('collectionManager', CollectionManager::class, true);
        $this->_services['dispatcher'] = new Service('dispatcher', ServiceDispatcher::class, true);
        $this->_services['errorViewHandler'] = new Service('errorViewHandler', function () {
            return $this->getShared(ServiceHandler::class);
        }, true);
        $this->_services['logger'] = new Service('logger', function () {
            $channel = APP['appname'].'.'.APP['env'];
            $logger = new Logger($channel);
            $config = $this->getShared('config');
            $stream = realpath($config['logPath']).'/app.'.date('Ymd').'.txt';
            $logger->pushHandler(new StreamHandler($stream));

            return $logger;
        }, true);
        $this->_services['errorLogger'] = new Service('errorLogger', function () {
            $logger = clone $this->get('logger');
            $logger->pushHandler(new EellyapiHandler());
            $_SERVER['UNIQUE_ID'] = APP['requestId'];
            
            $webProcessor = new WebProcessor(null, ['server', 'url', 'ip']);
            $webProcessor->addExtraField('server_ip', 'SERVER_ADDR');
            $logger->pushProcessor($webProcessor);

            return $logger;
        }, true);
        $this->_services['modelsManager'] = new Service('modelsManager', ModelsManager::class, true);
        $this->_services['request'] = new Service('request', ServiceRequest::class, true);
        $this->_services['response'] = new Service('response', ServiceResponse::class, true);
        $this->_services['router'] = new Service('router', ServiceRouter::class, true);
        $this->_services['transactionManager'] = new Service('transactionManager', TransactionManager::class, true);
    }
}<commit_msg>Apply fixes from StyleCI<commit_after><?php

declare(strict_types=1);

/*
 * This file is part of eelly package.
 *
 * (c) eelly.com
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Shadon\Di;

use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\WebProcessor;
use Phalcon\Di\Service;
use Shadon\Dispatcher\ServiceDispatcher;
use Shadon\Http\PhalconServiceResponse as ServiceResponse;
use Shadon\Http\ServiceRequest;
use Shadon\Logger\Handler\EellyapiHandler;
use Shadon\Logger\Handler\ServiceHandler;
use Shadon\Mvc\Collection\Manager as CollectionManager;
use Shadon\Mvc\Model\Manager as ModelsManager;
use Shadon\Mvc\Model\Transaction\Manager as TransactionManager;
use Shadon\Router\ServiceRouter;

/**
 * @author hehui<<EMAIL>>
 */
class ServiceDi extends FactoryDefault
{
    public function __construct()
    {
        parent::__construct();
        $this->_services['collectionManager'] = new Service('collectionManager', CollectionManager::class, true);
        $this->_services['dispatcher'] = new Service('dispatcher', ServiceDispatcher::class, true);
        $this->_services['errorViewHandler'] = new Service('errorViewHandler', function () {
            return $this->getShared(ServiceHandler::class);
        }, true);
        $this->_services['logger'] = new Service('logger', function () {
            $channel = APP['appname'].'.'.APP['env'];
            $logger = new Logger($channel);
            $config = $this->getShared('config');
            $stream = realpath($config['logPath']).'/app.'.date('Ymd').'.txt';
            $logger->pushHandler(new StreamHandler($stream));

            return $logger;
        }, true);
        $this->_services['errorLogger'] = new Service('errorLogger', function () {
            $logger = clone $this->get('logger');
            $logger->pushHandler(new EellyapiHandler());
            $_SERVER['UNIQUE_ID'] = APP['requestId'];

            $webProcessor = new WebProcessor(null, ['server', 'url', 'ip']);
            $webProcessor->addExtraField('server_ip', 'SERVER_ADDR');
            $logger->pushProcessor($webProcessor);

            return $logger;
        }, true);
        $this->_services['modelsManager'] = new Service('modelsManager', ModelsManager::class, true);
        $this->_services['request'] = new Service('request', ServiceRequest::class, true);
        $this->_services['response'] = new Service('response', ServiceResponse::class, true);
        $this->_services['router'] = new Service('router', ServiceRouter::class, true);
        $this->_services['transactionManager'] = new Service('transactionManager', TransactionManager::class, true);
    }
}
{'fraction_non_alphanumeric': 0.1485921889191644, 'fraction_numerical': 0.00036330608537693006, 'mean_word_length': 3.738382099827883, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 41, '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': '312567', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1471, 'n_words': 321}