<?php

namespace lib\Controllers;

use lib\Core\Controller as Core;
use lib\Models\ClientModel;
use lib\Models\ServiceModel;

class CommonController extends Core
{
    protected function __construct()
    {
        parent::__construct();
    } //

    final protected function getClientModel(): ClientModel
    {
        if ($this->_clientModel === null) {
            $this->_clientModel = new ClientModel();
        }
        return $this->_clientModel;
    }
    final protected function getServiceModel(): ServiceModel
    {
        if ($this->_serviceModel === null) {
            $this->_serviceModel = new ServiceModel();
        }
        return $this->_serviceModel;
    }

    final public function getSiteInfo(): array
    {
        $domain = array_key_exists("HTTP_HOST", $_SERVER) ? $_SERVER["HTTP_HOST"] : false;
        switch ($domain) {
            case 'dbms.prime-idc.jp':
                $datas = [
                    "id" => "PRIMEIDC",
                    "domain" => "dbms.prime-idc.jp",
                    "name" => "PrimeIDC",
                    "email" => "primeidc.jp@gmail.com",
                    "banks" => [
                        ["id" => "331301-04-217387", "name" => '국민은행', "owner" => "주)듀나미스"]
                    ],
                ];
                break;
            case "dbms.itsolution-idc.jp":
                $datas = [
                    "id"     => "ITSOLUTION",
                    "domain" => "dbms.itsolution-idc.jp",
                    "name"   => "Itsolution",
                    "email"  => "support@itsoution-idc.jp",
                    "banks"  => [
                        ["id" => "9002-1932-1654-1", "name" => '새마을금고', "owner" => "주식회사 르호봇"],
                        ["id" => "351-0995-6751-73", "name" => '농협', "owner" => "주식회사 르호봇"],
                    ],
                ];
                break;
            case 'dbms.gdidc.jp':
                $datas = [
                    "id" => "GDIDC",
                    "domain" => "dbms.gdidc.jp",
                    "name" => "GDIDC",
                    "email" => "support@gdidc.jp",
                    "banks" => [
                        ["id" => "1005-204-100758", "name" => '우리은행', "owner" => " (주)브엘라해로이"],
                    ],
                ];
                break;
            default:
                $datas = [];
                break;
        }
        return $datas;
    }
} //Class
