mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-01-24 19:51:14 +01:00
55 lines
1.1 KiB
PHP
55 lines
1.1 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 SplStack
|
|
*/
|
|
class SplStack extends \SplStack implements Serializable
|
|
{
|
|
/**
|
|
* Serialize to an array representing the stack
|
|
*
|
|
* @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->unshift($item);
|
|
}
|
|
}
|
|
}
|