<?php

namespace App\Services\TG\Hook\Mod;
//use App\Services\TomTool\Http;
//use App\Models\Article as ModelArticle;
use App\Services\TomTool\Http;
use App\Services\TG\Http as TGHttp;

class Base {
    
    public function __construct() {
        $this->oHttp = new Http();
        $this->oTGHttp = new TGHttp();
//        $this->oTGHttp->sApiToken = env("telegram_token");
//        $this->oTGHttp->sApiChatId = env("telegram_chatid");
    }
    
    protected function cmdGood($sCmd) {
        
        $sCmdNew = "";
        switch ($sCmd) {
            case "user":
                $sCmdNew = "user_name";
                break;
            case "project":
                $sCmdNew = "project_name";
                break;
            case "code":
                $sCmdNew = "sale_code";
                break;
            case "condition":
                $sCmdNew = "cron_condition";
                break;
            default:
                $sCmdNew = $sCmd;
                break;
        }
        
        return $sCmdNew;
        
    }
    
    public function toJson($aData)
    {
        $json = json_encode($aData, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
        
//        if ($sMsg) {
//            $sMsg = $sMsg."\n\n";
//        }
        
        $str = $json;
        
        return $str;
//        return json_encode($aData, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
    }
    
    public function urlFormat($sUrl)
    {
        $sUrlNew = str_replace('/', '$', $sUrl);
        return $sUrlNew;
    }
}
