Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Cache / Storage / Adapter / ApcIterator.php
blob66ac993ae9c99d3076b17907a06990f01de98920
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Cache\Storage\Adapter;
12 use APCIterator as BaseApcIterator;
13 use Zend\Cache\Storage\IteratorInterface;
15 class ApcIterator implements IteratorInterface
18 /**
19 * The apc storage instance
21 * @var Apc
23 protected $storage;
25 /**
26 * The iterator mode
28 * @var int
30 protected $mode = IteratorInterface::CURRENT_AS_KEY;
32 /**
33 * The base APCIterator instance
35 * @var BaseApcIterator
37 protected $baseIterator;
39 /**
40 * The length of the namespace prefix
42 * @var int
44 protected $prefixLength;
46 /**
47 * Constructor
49 * @param Apc $storage
50 * @param BaseApcIterator $baseIterator
51 * @param string $prefix
53 public function __construct(Apc $storage, BaseApcIterator $baseIterator, $prefix)
55 $this->storage = $storage;
56 $this->baseIterator = $baseIterator;
57 $this->prefixLength = strlen($prefix);
60 /**
61 * Get storage instance
63 * @return Apc
65 public function getStorage()
67 return $this->storage;
70 /**
71 * Get iterator mode
73 * @return int Value of IteratorInterface::CURRENT_AS_*
75 public function getMode()
77 return $this->mode;
80 /**
81 * Set iterator mode
83 * @param int $mode
84 * @return ApcIterator Fluent interface
86 public function setMode($mode)
88 $this->mode = (int) $mode;
89 return $this;
92 /* Iterator */
94 /**
95 * Get current key, value or metadata.
97 * @return mixed
99 public function current()
101 if ($this->mode == IteratorInterface::CURRENT_AS_SELF) {
102 return $this;
105 $key = $this->key();
107 if ($this->mode == IteratorInterface::CURRENT_AS_VALUE) {
108 return $this->storage->getItem($key);
109 } elseif ($this->mode == IteratorInterface::CURRENT_AS_METADATA) {
110 return $this->storage->getMetadata($key);
113 return $key;
117 * Get current key
119 * @return string
121 public function key()
123 $key = $this->baseIterator->key();
125 // remove namespace prefix
126 return substr($key, $this->prefixLength);
130 * Move forward to next element
132 * @return void
134 public function next()
136 $this->baseIterator->next();
140 * Checks if current position is valid
142 * @return bool
144 public function valid()
146 return $this->baseIterator->valid();
150 * Rewind the Iterator to the first element.
152 * @return void
154 public function rewind()
156 return $this->baseIterator->rewind();