![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/codeception/codeception/src/Codeception/ |
<?php declare(strict_types=1); namespace Codeception; use ArrayAccess; use ArrayIterator; use Countable; use IteratorAggregate; use PHPUnit\Framework\AssertionFailedError; use Traversable; class Example implements ArrayAccess, Countable, IteratorAggregate { public function __construct(protected $data) { } /** * Whether an offset exists * * @link https://php.net/manual/en/arrayaccess.offsetexists.php * @param mixed $offset <p>An offset to check for.</p> * @return bool true on success or false on failure. * The return value will be casted to boolean if non-boolean was returned. */ public function offsetExists(mixed $offset): bool { return array_key_exists($offset, $this->data); } /** * Offset to retrieve * * @link https://php.net/manual/en/arrayaccess.offsetget.php * @param mixed $offset <p>The offset to retrieve.</p> * @return mixed Can return all value types. */ public function offsetGet(mixed $offset): mixed { if (!$this->offsetExists($offset)) { throw new AssertionFailedError(sprintf("Example %s doesn't exist", $offset)); } return $this->data[$offset]; } /** * Offset to set * * @link https://php.net/manual/en/arrayaccess.offsetset.php * @param mixed $offset <p>The offset to assign the value to.</p> * @param mixed $value <p>The value to set.</p> */ public function offsetSet(mixed $offset, mixed $value): void { $this->data[$offset] = $value; } /** * Offset to unset * * @link https://php.net/manual/en/arrayaccess.offsetunset.php * @param mixed $offset <p>The offset to unset.</p> */ public function offsetUnset(mixed $offset): void { unset($this->data[$offset]); } /** * Count elements of an object * * @link https://php.net/manual/en/countable.count.php * @return int The custom count as an integer. * The return value is cast to an integer. */ public function count(): int { return count($this->data); } /** * Retrieve an external iterator * * @link https://php.net/manual/en/iteratoraggregate.getiterator.php * @return Traversable An instance of an object implementing <b>Iterator</b> or <b>Traversable</b> */ public function getIterator(): Traversable { return new ArrayIterator($this->data); } }