@@ 34-105 (lines=72) @@ | ||
31 | * @link https://github.com/appserver-io/messaging |
|
32 | * @link http://www.appserver.io |
|
33 | */ |
|
34 | class IntegerMessage extends AbstractMessage |
|
35 | { |
|
36 | ||
37 | /** |
|
38 | * The message id as hash value. |
|
39 | * |
|
40 | * @var string |
|
41 | */ |
|
42 | protected $messageId = null; |
|
43 | ||
44 | /** |
|
45 | * The message itself. |
|
46 | * |
|
47 | * @var integer |
|
48 | */ |
|
49 | protected $message = null; |
|
50 | ||
51 | /** |
|
52 | * Initializes the message with the Integer |
|
53 | * to send to the queue. |
|
54 | * |
|
55 | * @param integer $message The integer with the data to send |
|
56 | * |
|
57 | * @throws \Exception Is thrown if the passed message is not a valid integer value |
|
58 | */ |
|
59 | public function __construct($message) |
|
60 | { |
|
61 | ||
62 | // call parent constructor |
|
63 | parent::__construct(); |
|
64 | ||
65 | // check if we've an integer passed |
|
66 | if (is_integer($message) === false) { |
|
67 | throw new \Exception(sprintf('Message \'%s\' is not a valid integer', $message)); |
|
68 | } |
|
69 | ||
70 | // initialize the integer sent with the message |
|
71 | $this->message = $message; |
|
72 | // initialize the message id |
|
73 | $this->messageId = Uuid::uuid4()->__toString(); |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * Returns the unique message-ID. |
|
78 | * |
|
79 | * @return string The unique message-ID |
|
80 | */ |
|
81 | public function getMessageId() |
|
82 | { |
|
83 | return $this->messageId; |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * The message itself. |
|
88 | * |
|
89 | * @return integer The message itself |
|
90 | */ |
|
91 | public function getMessage() |
|
92 | { |
|
93 | return $this->message; |
|
94 | } |
|
95 | ||
96 | /** |
|
97 | * Returns the message as string. |
|
98 | * |
|
99 | * @return string The message as string |
|
100 | */ |
|
101 | public function __toString() |
|
102 | { |
|
103 | return "'" . $this->message . "'"; |
|
104 | } |
|
105 | } |
|
106 |
@@ 35-106 (lines=72) @@ | ||
32 | * @link https://github.com/appserver-io/messaging |
|
33 | * @link http://www.appserver.io |
|
34 | */ |
|
35 | class StringMessage extends AbstractMessage |
|
36 | { |
|
37 | ||
38 | /** |
|
39 | * The message id as hash value. |
|
40 | * |
|
41 | * @var string |
|
42 | */ |
|
43 | protected $messageId = null; |
|
44 | ||
45 | /** |
|
46 | * The message itself. |
|
47 | * |
|
48 | * @var string |
|
49 | */ |
|
50 | protected $message = null; |
|
51 | ||
52 | /** |
|
53 | * Initializes the message with the String |
|
54 | * to send to the queue. |
|
55 | * |
|
56 | * @param string $message The string with the data to send |
|
57 | * |
|
58 | * @throws \Exception Is thrown if the passed message is not a valid string value |
|
59 | */ |
|
60 | public function __construct($message) |
|
61 | { |
|
62 | ||
63 | // call parent constructor |
|
64 | parent::__construct(); |
|
65 | ||
66 | // check if we've an string passed |
|
67 | if (is_string($message) === false) { |
|
68 | throw new \Exception(sprintf('Message \'%s\' is not a valid string', $message)); |
|
69 | } |
|
70 | ||
71 | // initialize the String sent with the message |
|
72 | $this->message = $message; |
|
73 | // initialize the message-ID |
|
74 | $this->messageId = Uuid::uuid4()->__toString(); |
|
75 | } |
|
76 | ||
77 | /** |
|
78 | * Returns the unique message-ID. |
|
79 | * |
|
80 | * @return string The unique message-ID |
|
81 | */ |
|
82 | public function getMessageId() |
|
83 | { |
|
84 | return $this->messageId; |
|
85 | } |
|
86 | ||
87 | /** |
|
88 | * The message itself. |
|
89 | * |
|
90 | * @return string The message itself |
|
91 | */ |
|
92 | public function getMessage() |
|
93 | { |
|
94 | return $this->message; |
|
95 | } |
|
96 | ||
97 | /** |
|
98 | * Returns the message as string. |
|
99 | * |
|
100 | * @return string The message as string |
|
101 | */ |
|
102 | public function __toString() |
|
103 | { |
|
104 | return $this->message; |
|
105 | } |
|
106 | } |
|
107 |