クラス
Utils
ソース ソース
ファイル: src/V1/Utils.php
final class Utils
{
    /**
     * Prevents instantiation of this class.
     *
     * @throws Exception Thrown if instantiation is attempted.
     */
    private function __construct() {
        throw new Exception("Can't create instance of this class");
    }
    /**
     * Prepares error response object for nag dialog box.
     *
     * @author Evan D Shaw <evandanielshaw@gmail.com>
     * @param string $method
     * @param string $amazon_order_status
     * @return array
     */
    public static function adminErrorResponse($method, $amazon_order_status) {
        $res = [];
        switch ($amazon_order_status) {
            case 'captured':
                $res['message'] = __('This order has already been captured. It cannot be modified.', 'wcexaap');
                break;
            case 'canceled':
                $res['message'] = __('This order has already been cancelled. It cannot be modified.', 'wcexaap');
                break;
        }
        $res['method'] = $method;
        $res['status'] = 'error';
        return $res;
    }
    /**
     * Prepares admin message string to be displayed at the top of the admin panel.
     *
     * @author Evan D Shaw <evandanielshaw@gmail.com>
     * @param int     $order_id
     * @param string  $status
     * @param string  $message
     * @param boolean $success_msg
     * @return string
     */
    public static function adminMessageString($order_id, $status, $message, $success_msg = false) {
        $msgstr = '';
        switch ($status) {
            case 'error':
                $msgstr = 'ERROR (ORDER_ID ' . $order_id . ')<br/>[Amazon Pay] -> ' . $message;
                break;
            case 'success':
                if ($success_msg) {
                    $msgstr = 'SUCCESS (ORDER_ID ' . $order_id . ')<br/>[Amazon Pay] -> ' . $message;
                }
                break;
        }
        return $msgstr;
    }
}
- __construct — Prevents instantiation of this class.
- adminErrorResponse — Prepares error response object for nag dialog box.
- adminMessageString — Prepares admin message string to be displayed at the top of the admin panel.