Skip to content

Commit f95c677

Browse files
committed
Merge pull request #52 from dovg/TextMessageFix
a bit optimize: don't needed to make Timestamp twice
2 parents f68cfb5 + fa32c36 commit f95c677

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

doc/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2011-11-18 Evgeny V. Kokovikhin
2+
3+
* main/Messages/TextMessage.class.php, main/Messages/TextFileReceiver.class.php :
4+
a bit optimize: don't needed to make Timestamp twice
5+
16
2011-11-14 Dmitry V. Snezhinskiy
27

38
* main/Utils/AMQP/Pecl/AMQPPeclChannel.class.php :

main/Messages/TextFileReceiver.class.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public function receive($uTimeout = null)
6969

7070
Assert::isNotNull($time);
7171

72-
$result = TextMessage::create()->
73-
setTimestamp(Timestamp::create($time))->
72+
$result = TextMessage::create(Timestamp::create($time))->
7473
setText($text);
7574

7675
return $result;

main/Messages/TextMessage.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ final class TextMessage implements Message
1515
private $timestamp = null;
1616
private $text = null;
1717

18-
public static function create()
18+
public static function create(Timestamp $timestamp = null)
1919
{
20-
return new self;
20+
return new self($timestamp);
2121
}
2222

23-
public function __construct()
23+
public function __construct(Timestamp $timestamp = null)
2424
{
25-
$this->timestamp = Timestamp::makeNow();
25+
$this->timestamp = $timestamp ?: Timestamp::makeNow();
2626
}
2727

28-
public function setTimestamp($timestamp)
28+
public function setTimestamp(Timestamp $timestamp)
2929
{
3030
$this->timestamp = $timestamp;
3131

0 commit comments

Comments
 (0)