Install zendframework via composer, update build.xml and run, updates to composer
[openemr.git] / vendor / zendframework / zendframework / library / Zend / Stdlib / Parameters.php
blobbef834a8a03ade6a62e21b78d9efeb1be79e35e4
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-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Stdlib;
12 use ArrayObject as PhpArrayObject;
14 class Parameters extends PhpArrayObject implements ParametersInterface
16 /**
17 * Constructor
19 * Enforces that we have an array, and enforces parameter access to array
20 * elements.
22 * @param array $values
24 public function __construct(array $values = null)
26 if (null === $values) {
27 $values = array();
29 parent::__construct($values, ArrayObject::ARRAY_AS_PROPS);
32 /**
33 * Populate from native PHP array
35 * @param array $values
36 * @return void
38 public function fromArray(array $values)
40 $this->exchangeArray($values);
43 /**
44 * Populate from query string
46 * @param string $string
47 * @return void
49 public function fromString($string)
51 $array = array();
52 parse_str($string, $array);
53 $this->fromArray($array);
56 /**
57 * Serialize to native PHP array
59 * @return array
61 public function toArray()
63 return $this->getArrayCopy();
66 /**
67 * Serialize to query string
69 * @return string
71 public function toString()
73 return http_build_query($this);
76 /**
77 * Retrieve by key
79 * Returns null if the key does not exist.
81 * @param string $name
82 * @return mixed
84 public function offsetGet($name)
86 if ($this->offsetExists($name)) {
87 return parent::offsetGet($name);
89 return;
92 /**
93 * @param string $name
94 * @param mixed $default optional default value
95 * @return mixed
97 public function get($name, $default = null)
99 if ($this->offsetExists($name)) {
100 return parent::offsetGet($name);
102 return $default;
106 * @param string $name
107 * @param mixed $value
108 * @return Parameters
110 public function set($name, $value)
112 $this[$name] = $value;
113 return $this;