1<?php
2/**
3 * This file is part of the FreeDSx Socket package.
4 *
5 * (c) Chad Sikorra <Chad.Sikorra@gmail.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11namespace FreeDSx\Socket\Queue;
12
13/**
14 * Represents the decoded result from a message queue.
15 *
16 * @author Chad Sikorra <Chad.Sikorra@gmail.com>
17 */
18class Message
19{
20    /**
21     * @var mixed
22     */
23    protected $message;
24
25    /**
26     * @var null|int
27     */
28    protected $lastPosition;
29
30    /**
31     * @param mixed $message The message object as the result of the socket data.
32     * @param null|int $lastPosition the last position of the byte stream after this message.
33     */
34    public function __construct($message, ?int $lastPosition = null)
35    {
36        $this->message = $message;
37        $this->lastPosition = $lastPosition;
38    }
39
40    /**
41     * Get the message object as the result of the socket data.
42     *
43     * @return mixed
44     */
45    public function getMessage()
46    {
47        return $this->message;
48    }
49
50    /**
51     * Get the last position of the byte stream after this message.
52     *
53     * @return null|int
54     */
55    public function getLastPosition(): ?int
56    {
57        return $this->lastPosition;
58    }
59}
60