<?php


class Response
{

    public static function respondSuccess($msg)
    {
        $response = [
            'msg'   => $msg,
            'error' => 0
        ];

        return Response::_respond($response);
    }

    public static function respondData($data)
    {
        $response = [
            'error' => 0,
            'data'  => $data
        ];

        return Response::_respond($response);
    }

    public static function respondError($code)
    {
        $msg = Config::getMsg($code);

        $response = [
            'msg'   => $msg,
            'error' => $code
        ];

        return Response::_respond($response);
    }

    private static function _respond($response)
    {
        return json_encode($response);
    }
}