Skip to content

Commit 0b754d3

Browse files
committed
a bit optimize: don't needed to make Timestamp twice
1 parent f68cfb5 commit 0b754d3

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

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: 4 additions & 4 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
{
2020
return new self;
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)