Update objects to use __toString()

This commit is contained in:
Deon George
2020-06-24 22:37:14 +10:00
parent 358f28273c
commit 9936e839a4
15 changed files with 145 additions and 78 deletions

View File

@@ -48,6 +48,17 @@ class Message implements \IteratorAggregate,\ArrayAccess
$this->packets = $packets;
}
public function __toString()
{
$result = '';
foreach ($this as $p) {
$result .= (string)$p;
}
return $result;
}
/**
* @see http://tools.ietf.org/html/rfc4880#section-4.1
* @see http://tools.ietf.org/html/rfc4880#section-4.2
@@ -192,7 +203,7 @@ class Message implements \IteratorAggregate,\ArrayAccess
$bytes = '';
foreach ($this as $p) {
$bytes .= $p->to_bytes();
$bytes .= (string)$p;
}
return $bytes;