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 / Memory / Value.php
blob0c8de61496ee0a7ebec6b6e57b5e1d86d5391448
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\Memory;
12 use ArrayAccess;
13 use Countable;
15 /**
16 * String value object
18 * It's an OO string wrapper.
19 * Used to intercept string updates.
21 class Value implements ArrayAccess, Countable
23 /**
24 * Value
26 * @var string
28 private $value;
30 /**
31 * Container
33 * @var Container\Movable
35 private $container;
37 /**
38 * Boolean flag which signals to trace value modifications
40 * @var bool
42 private $trace;
45 /**
46 * Object constructor
48 * @param string $value
49 * @param \Zend\Memory\Container\Movable $container
51 public function __construct($value, Container\Movable $container)
53 $this->container = $container;
55 $this->value = (string) $value;
57 /**
58 * Object is marked as just modified by memory manager
59 * So we don't need to trace followed object modifications and
60 * object is processed (and marked as traced) when another
61 * memory object is modified.
63 * It reduces overall number of calls necessary to modification trace
65 $this->trace = false;
68 /**
69 * Countable
71 * @return int
73 public function count()
75 return strlen($this->value);
78 /**
79 * ArrayAccess interface method
80 * returns true if string offset exists
82 * @param int $offset
83 * @return bool
85 public function offsetExists($offset)
87 return $offset >= 0 && $offset < strlen($this->value);
90 /**
91 * ArrayAccess interface method
92 * Get character at $offset position
94 * @param int $offset
95 * @return string
97 public function offsetGet($offset)
99 return $this->value[$offset];
103 * ArrayAccess interface method
104 * Set character at $offset position
106 * @param int $offset
107 * @param string $char
109 public function offsetSet($offset, $char)
111 $this->value[$offset] = $char;
113 if ($this->trace) {
114 $this->trace = false;
115 $this->container->processUpdate();
120 * ArrayAccess interface method
121 * Unset character at $offset position
123 * @param int $offset
125 public function offsetUnset($offset)
127 unset($this->value[$offset]);
129 if ($this->trace) {
130 $this->trace = false;
131 $this->container->processUpdate();
137 * To string conversion
139 * @return string
141 public function __toString()
143 return $this->value;
148 * Get string value reference
150 * _Must_ be used for value access before PHP v 5.2
151 * or _may_ be used for performance considerations
153 * @internal
154 * @return string
156 public function &getRef()
158 return $this->value;
162 * Start modifications trace
164 * _Must_ be used for value access before PHP v 5.2
165 * or _may_ be used for performance considerations
167 * @internal
169 public function startTrace()
171 $this->trace = true;