Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Pool.php
Go to the documentation of this file.
1 <?php
8 
15 class Pool implements \Iterator, \ArrayAccess
16 {
20  protected $prices;
21 
26  public function __construct(
27  array $prices,
28  \Iterator $target = null
29  ) {
30  $this->prices = $prices;
31  foreach ($target ?: [] as $code => $class) {
32  if (empty($this->prices[$code])) {
33  $this->prices[$code] = $class;
34  }
35  }
36  }
37 
43  public function rewind()
44  {
45  return reset($this->prices);
46  }
47 
53  public function current()
54  {
55  return current($this->prices);
56  }
57 
63  public function key()
64  {
65  return key($this->prices);
66  }
67 
73  public function next()
74  {
75  return next($this->prices);
76  }
77 
83  public function valid()
84  {
85  return (bool)$this->key();
86  }
87 
94  public function get($code)
95  {
96  return $this->prices[$code];
97  }
98 
106  public function offsetSet($offset, $value)
107  {
108  if ($offset === null) {
109  $this->prices[] = $value;
110  } else {
111  $this->prices[$offset] = $value;
112  }
113  }
114 
121  public function offsetExists($offset)
122  {
123  return isset($this->prices[$offset]);
124  }
125 
132  public function offsetUnset($offset)
133  {
134  unset($this->prices[$offset]);
135  }
136 
143  public function offsetGet($offset)
144  {
145  return $this->prices[$offset] ?? null;
146  }
147 }
$target
Definition: skip.phtml:8
$_option $_optionId $class
Definition: date.phtml:13
$value
Definition: gender.phtml:16
__construct(array $prices, \Iterator $target=null)
Definition: Pool.php:26
$code
Definition: info.phtml:12