[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/zendframework/zend-stdlib/src/ -> Parameters.php (source)

   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 ArrayObject as PhpArrayObject;
  13  
  14  class Parameters extends PhpArrayObject implements ParametersInterface
  15  {
  16      /**
  17       * Constructor
  18       *
  19       * Enforces that we have an array, and enforces parameter access to array
  20       * elements.
  21       *
  22       * @param  array $values
  23       */
  24      public function __construct(array $values = null)
  25      {
  26          if (null === $values) {
  27              $values = array();
  28          }
  29          parent::__construct($values, ArrayObject::ARRAY_AS_PROPS);
  30      }
  31  
  32      /**
  33       * Populate from native PHP array
  34       *
  35       * @param  array $values
  36       * @return void
  37       */
  38      public function fromArray(array $values)
  39      {
  40          $this->exchangeArray($values);
  41      }
  42  
  43      /**
  44       * Populate from query string
  45       *
  46       * @param  string $string
  47       * @return void
  48       */
  49      public function fromString($string)
  50      {
  51          $array = array();
  52          parse_str($string, $array);
  53          $this->fromArray($array);
  54      }
  55  
  56      /**
  57       * Serialize to native PHP array
  58       *
  59       * @return array
  60       */
  61      public function toArray()
  62      {
  63          return $this->getArrayCopy();
  64      }
  65  
  66      /**
  67       * Serialize to query string
  68       *
  69       * @return string
  70       */
  71      public function toString()
  72      {
  73          return http_build_query($this);
  74      }
  75  
  76      /**
  77       * Retrieve by key
  78       *
  79       * Returns null if the key does not exist.
  80       *
  81       * @param  string $name
  82       * @return mixed
  83       */
  84      public function offsetGet($name)
  85      {
  86          if ($this->offsetExists($name)) {
  87              return parent::offsetGet($name);
  88          }
  89          return;
  90      }
  91  
  92      /**
  93       * @param string $name
  94       * @param mixed $default optional default value
  95       * @return mixed
  96       */
  97      public function get($name, $default = null)
  98      {
  99          if ($this->offsetExists($name)) {
 100              return parent::offsetGet($name);
 101          }
 102          return $default;
 103      }
 104  
 105      /**
 106       * @param string $name
 107       * @param mixed $value
 108       * @return Parameters
 109       */
 110      public function set($name, $value)
 111      {
 112          $this[$name] = $value;
 113          return $this;
 114      }
 115  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1