<?php
return [
    'databases' => function() {
        $container = new DI\Container([
            ORM::DEFAULT_CONNECTION => new DI\Container([
                'host' => $_ENV['MYSQL_HOST'],
                'database' => $_ENV['MYSQL_DATABASE'],
                'username' => $_ENV['MYSQL_USER'],
                'password' => $_ENV['MYSQL_PASSWORD']
            ]),
            'remote' => new DI\Container([
                'host' => $_ENV['REMOTE_HOST'],
                'database' => $_ENV['REMOTE_DATABASE'],
                'username' => $_ENV['REMOTE_USER'],
                'password' => $_ENV['REMOTE_PASSWORD']
            ])
        ]);
        if (isset($_ENV['MYSQL_PORT'])) {
            $container->get(ORM::DEFAULT_CONNECTION)->set('port', $_ENV['MYSQL_PORT']);
        }
        if (isset($_ENV['REMOTE_PORT'])) {
            $container->get('remote')->set('port', $_ENV['REMOTE_PORT']);
        }
        return $container;
    }
];
