public static function jsonResponseFormatter($type, $data, $code = 200, $status = Status::OK, $message = '')
    {
        // Validate the arguments.
        if ($status == Status::OK && empty($type)) {
            throw new Exception('Cannot prepare response. No type specified');
        }
        else {
            $type = preg_replace('/[^A-Za-z]/si', '_', strtolower($type));
        }

        // Ensure the data is in an array.
        if (is_object($data)) {
            $data = [(array) $data];
        }

        // Prepare the response object.
        $response = new stdClass();
        $response->status = $status;
        $response->code = $code;
        $response->message = $message;

        // Return data in an array.
        if (!empty($data)) {
            $response->data = new stdClass();
            $response->data->{$type} = $data;
        } elseif (!empty($type)) {
            // Return an empty array even if there are no data.
            $response->data = new stdClass();
            $response->data->{$type} = [];
        }

        return $response;
    }