Update objects to use __toString()
This commit is contained in:
@@ -9,18 +9,9 @@ class Subpacket extends Packet
|
||||
{
|
||||
protected $tag = NULL;
|
||||
|
||||
function body()
|
||||
protected function header_and_body(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
function header_and_body(): array
|
||||
{
|
||||
$body = $this->body(); // Get body first, we will need it's length
|
||||
$size = chr(255).pack('N',strlen($body)+1); // Use 5-octet lengths + 1 for tag as first packet body octet
|
||||
$tag = chr($this->tag);
|
||||
|
||||
return ['header'=>$size.$tag,'body'=>$body];
|
||||
return ['header'=>$this->size().chr($this->tag),'body'=>$this->body()];
|
||||
}
|
||||
|
||||
/* Defaults for unsupported packets */
|
||||
@@ -36,4 +27,10 @@ class Subpacket extends Packet
|
||||
|
||||
$this->tag = $tag;
|
||||
}
|
||||
|
||||
protected function size(): string
|
||||
{
|
||||
// Use 5-octet lengths + 1 for tag as first packet body octet
|
||||
return chr(255).pack('N',strlen($this->body())+1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user