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