public function serialize($jobId, $class, $args = [], $retry = true, $queue = null)
    {
        $class = is_object($class) ? get_class($class) : $class;

        $data = [
            'class' => $class,
            'jid' => $jobId,
            'created_at' => microtime(true),
            'enqueued_at' => microtime(true),
            'args' => $args,
            'retry' => $retry,
        ];

        if ($queue !== null) {
            $data['queue'] = $queue;
        }

        $jsonEncodedData = json_encode($data);

        if ($jsonEncodedData === false) {
            throw new JsonEncodeException($data, json_last_error(), json_last_error_msg());
        }

        return $jsonEncodedData;
    }