func = $func; } /** * Determine if the content has been fetched. * * @return bool */ public function isLoaded() { return $this->cache !== NULL; } public function load($force = FALSE) { if ($this->cache === NULL || $force) { $this->cache = CRM_Utils_Array::cast(call_user_func($this->func)); } return $this; } public function offsetExists($offset): bool { return isset($this->load()->cache[$offset]); } #[\ReturnTypeWillChange] public function &offsetGet($offset) { return $this->load()->cache[$offset]; } public function offsetSet($offset, $value): void { if ($offset === NULL) { $this->load()->cache[] = $value; } else { $this->load()->cache[$offset] = $value; } } public function offsetUnset($offset): void { unset($this->load()->cache[$offset]); } #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->load()->cache); } /** * @return array */ public function getArrayCopy() { return $this->load()->cache; } public function count(): int { return count($this->load()->cache); } }