3 * Zend Framework (http://framework.zend.com/)
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
10 namespace Zend\Stdlib
;
12 use ArrayObject
as PhpArrayObject
;
14 class Parameters
extends PhpArrayObject
implements ParametersInterface
19 * Enforces that we have an array, and enforces parameter access to array
22 * @param array $values
24 public function __construct(array $values = null)
26 if (null === $values) {
29 parent
::__construct($values, ArrayObject
::ARRAY_AS_PROPS
);
33 * Populate from native PHP array
35 * @param array $values
38 public function fromArray(array $values)
40 $this->exchangeArray($values);
44 * Populate from query string
46 * @param string $string
49 public function fromString($string)
52 parse_str($string, $array);
53 $this->fromArray($array);
57 * Serialize to native PHP array
61 public function toArray()
63 return $this->getArrayCopy();
67 * Serialize to query string
71 public function toString()
73 return http_build_query($this);
79 * Returns null if the key does not exist.
84 public function offsetGet($name)
86 if ($this->offsetExists($name)) {
87 return parent
::offsetGet($name);
94 * @param mixed $default optional default value
97 public function get($name, $default = null)
99 if ($this->offsetExists($name)) {
100 return parent
::offsetGet($name);
106 * @param string $name
107 * @param mixed $value
110 public function set($name, $value)
112 $this[$name] = $value;