mailpoet
/
vendor-prefixed
/
doctrine
/
collections
/
lib
/
Doctrine
/
Common
/
Collections
/
AbstractLazyCollection.php
mailpoet
/
vendor-prefixed
/
doctrine
/
collections
/
lib
/
Doctrine
/
Common
/
Collections
Last commit date
Expr
9 months ago
AbstractLazyCollection.php
9 months ago
ArrayCollection.php
4 years ago
Collection.php
9 months ago
Criteria.php
9 months ago
ExpressionBuilder.php
4 years ago
ReadableCollection.php
9 months ago
Selectable.php
4 years ago
index.php
3 years ago
AbstractLazyCollection.php
185 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\Common\Collections; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use Closure; |
| 5 | use LogicException; |
| 6 | use ReturnTypeWillChange; |
| 7 | use Traversable; |
| 8 | abstract class AbstractLazyCollection implements Collection |
| 9 | { |
| 10 | protected $collection; |
| 11 | protected $initialized = \false; |
| 12 | #[\ReturnTypeWillChange] |
| 13 | public function count() |
| 14 | { |
| 15 | $this->initialize(); |
| 16 | return $this->collection->count(); |
| 17 | } |
| 18 | public function add($element) |
| 19 | { |
| 20 | $this->initialize(); |
| 21 | return $this->collection->add($element); |
| 22 | } |
| 23 | public function clear() |
| 24 | { |
| 25 | $this->initialize(); |
| 26 | $this->collection->clear(); |
| 27 | } |
| 28 | public function contains($element) |
| 29 | { |
| 30 | $this->initialize(); |
| 31 | return $this->collection->contains($element); |
| 32 | } |
| 33 | public function isEmpty() |
| 34 | { |
| 35 | $this->initialize(); |
| 36 | return $this->collection->isEmpty(); |
| 37 | } |
| 38 | public function remove($key) |
| 39 | { |
| 40 | $this->initialize(); |
| 41 | return $this->collection->remove($key); |
| 42 | } |
| 43 | public function removeElement($element) |
| 44 | { |
| 45 | $this->initialize(); |
| 46 | return $this->collection->removeElement($element); |
| 47 | } |
| 48 | public function containsKey($key) |
| 49 | { |
| 50 | $this->initialize(); |
| 51 | return $this->collection->containsKey($key); |
| 52 | } |
| 53 | public function get($key) |
| 54 | { |
| 55 | $this->initialize(); |
| 56 | return $this->collection->get($key); |
| 57 | } |
| 58 | public function getKeys() |
| 59 | { |
| 60 | $this->initialize(); |
| 61 | return $this->collection->getKeys(); |
| 62 | } |
| 63 | public function getValues() |
| 64 | { |
| 65 | $this->initialize(); |
| 66 | return $this->collection->getValues(); |
| 67 | } |
| 68 | public function set($key, $value) |
| 69 | { |
| 70 | $this->initialize(); |
| 71 | $this->collection->set($key, $value); |
| 72 | } |
| 73 | public function toArray() |
| 74 | { |
| 75 | $this->initialize(); |
| 76 | return $this->collection->toArray(); |
| 77 | } |
| 78 | public function first() |
| 79 | { |
| 80 | $this->initialize(); |
| 81 | return $this->collection->first(); |
| 82 | } |
| 83 | public function last() |
| 84 | { |
| 85 | $this->initialize(); |
| 86 | return $this->collection->last(); |
| 87 | } |
| 88 | public function key() |
| 89 | { |
| 90 | $this->initialize(); |
| 91 | return $this->collection->key(); |
| 92 | } |
| 93 | public function current() |
| 94 | { |
| 95 | $this->initialize(); |
| 96 | return $this->collection->current(); |
| 97 | } |
| 98 | public function next() |
| 99 | { |
| 100 | $this->initialize(); |
| 101 | return $this->collection->next(); |
| 102 | } |
| 103 | public function exists(Closure $p) |
| 104 | { |
| 105 | $this->initialize(); |
| 106 | return $this->collection->exists($p); |
| 107 | } |
| 108 | public function filter(Closure $p) |
| 109 | { |
| 110 | $this->initialize(); |
| 111 | return $this->collection->filter($p); |
| 112 | } |
| 113 | public function forAll(Closure $p) |
| 114 | { |
| 115 | $this->initialize(); |
| 116 | return $this->collection->forAll($p); |
| 117 | } |
| 118 | public function map(Closure $func) |
| 119 | { |
| 120 | $this->initialize(); |
| 121 | return $this->collection->map($func); |
| 122 | } |
| 123 | public function partition(Closure $p) |
| 124 | { |
| 125 | $this->initialize(); |
| 126 | return $this->collection->partition($p); |
| 127 | } |
| 128 | public function indexOf($element) |
| 129 | { |
| 130 | $this->initialize(); |
| 131 | return $this->collection->indexOf($element); |
| 132 | } |
| 133 | public function slice($offset, $length = null) |
| 134 | { |
| 135 | $this->initialize(); |
| 136 | return $this->collection->slice($offset, $length); |
| 137 | } |
| 138 | #[\ReturnTypeWillChange] |
| 139 | public function getIterator() |
| 140 | { |
| 141 | $this->initialize(); |
| 142 | return $this->collection->getIterator(); |
| 143 | } |
| 144 | #[\ReturnTypeWillChange] |
| 145 | public function offsetExists($offset) |
| 146 | { |
| 147 | $this->initialize(); |
| 148 | return $this->collection->offsetExists($offset); |
| 149 | } |
| 150 | #[\ReturnTypeWillChange] |
| 151 | public function offsetGet($offset) |
| 152 | { |
| 153 | $this->initialize(); |
| 154 | return $this->collection->offsetGet($offset); |
| 155 | } |
| 156 | #[\ReturnTypeWillChange] |
| 157 | public function offsetSet($offset, $value) |
| 158 | { |
| 159 | $this->initialize(); |
| 160 | $this->collection->offsetSet($offset, $value); |
| 161 | } |
| 162 | #[\ReturnTypeWillChange] |
| 163 | public function offsetUnset($offset) |
| 164 | { |
| 165 | $this->initialize(); |
| 166 | $this->collection->offsetUnset($offset); |
| 167 | } |
| 168 | public function isInitialized() |
| 169 | { |
| 170 | return $this->initialized; |
| 171 | } |
| 172 | protected function initialize() |
| 173 | { |
| 174 | if ($this->initialized) { |
| 175 | return; |
| 176 | } |
| 177 | $this->doInitialize(); |
| 178 | $this->initialized = \true; |
| 179 | if ($this->collection === null) { |
| 180 | throw new LogicException('You must initialize the collection property in the doInitialize() method.'); |
| 181 | } |
| 182 | } |
| 183 | protected abstract function doInitialize(); |
| 184 | } |
| 185 |