mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-02-06 09:41:06 +01:00
55 lines
1.0 KiB
PHP
55 lines
1.0 KiB
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* @see https://github.com/laminas/laminas-stdlib for the canonical source repository
|
||
|
* @copyright https://github.com/laminas/laminas-stdlib/blob/master/COPYRIGHT.md
|
||
|
* @license https://github.com/laminas/laminas-stdlib/blob/master/LICENSE.md New BSD License
|
||
|
*/
|
||
|
|
||
|
namespace Laminas\Stdlib;
|
||
|
|
||
|
use Serializable;
|
||
|
|
||
|
/**
|
||
|
* Serializable version of SplQueue
|
||
|
*/
|
||
|
class SplQueue extends \SplQueue implements Serializable
|
||
|
{
|
||
|
/**
|
||
|
* Return an array representing the queue
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
public function toArray()
|
||
|
{
|
||
|
$array = [];
|
||
|
foreach ($this as $item) {
|
||
|
$array[] = $item;
|
||
|
}
|
||
|
return $array;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Serialize
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
public function serialize()
|
||
|
{
|
||
|
return serialize($this->toArray());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Unserialize
|
||
|
*
|
||
|
* @param string $data
|
||
|
* @return void
|
||
|
*/
|
||
|
public function unserialize($data)
|
||
|
{
|
||
|
foreach (unserialize($data) as $item) {
|
||
|
$this->push($item);
|
||
|
}
|
||
|
}
|
||
|
}
|