51d8daf7cce5e9f6d43d8697e6321fc4c520f620
[yaffs-website] / vendor / zendframework / zend-stdlib / src / SplQueue.php
1 <?php
2 /**
3  * Zend Framework (http://framework.zend.com/)
4  *
5  * @link      http://github.com/zendframework/zf2 for the canonical source repository
6  * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7  * @license   http://framework.zend.com/license/new-bsd New BSD License
8  */
9
10 namespace Zend\Stdlib;
11
12 use Serializable;
13
14 /**
15  * Serializable version of SplQueue
16  */
17 class SplQueue extends \SplQueue implements Serializable
18 {
19     /**
20      * Return an array representing the queue
21      *
22      * @return array
23      */
24     public function toArray()
25     {
26         $array = [];
27         foreach ($this as $item) {
28             $array[] = $item;
29         }
30         return $array;
31     }
32
33     /**
34      * Serialize
35      *
36      * @return string
37      */
38     public function serialize()
39     {
40         return serialize($this->toArray());
41     }
42
43     /**
44      * Unserialize
45      *
46      * @param  string $data
47      * @return void
48      */
49     public function unserialize($data)
50     {
51         foreach (unserialize($data) as $item) {
52             $this->push($item);
53         }
54     }
55 }