Skip to content

Commit

Permalink
Merge pull request #105 from skaut/2-serialize
Browse files Browse the repository at this point in the history
implmenet __serialize and __unserialize
  • Loading branch information
sinacek committed Apr 2, 2023
2 parents 60cf2c6 + 4273576 commit a676c62
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/SkautisQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ public function __construct($fname, array $args = [], array $trace = [])
$this->time = -microtime(true);
}

/**
* @deprecated use __serialize
*/
public function serialize()
{
return serialize($this->__serialize());
}

public function __serialize(): array
{
$data = [
'fname' => $this->fname,
Expand All @@ -81,12 +89,19 @@ public function serialize()
'exception_class' => is_null($this->exception) ? "" : get_class($this->exception),
'exception_string' => is_null($this->exception) ? "" : (string)$this->exception,
];
return serialize($data);
return $data;
}

/**
* @deprecated use __unserialize
*/
public function unserialize($data)
{
$data = unserialize($data);
$this->__unserialize(unserialize($data));
}

public function __unserialize(array $data): void
{
$this->fname = $data['fname'];
$this->args = $data['args'];
$this->trace = $data['trace'];
Expand Down

0 comments on commit a676c62

Please sign in to comment.