. */ /** * For more information, please contact */ namespace Goat1000\SVGGraph; class ColourArray implements \ArrayAccess { private $colours; private $count; public function __construct($colours) { $this->colours = $colours; $this->count = count($colours); } /** * Not used by this class */ public function setup($count) { // count comes from array, not number of bars etc. } /** * always true, because it wraps around */ #[\ReturnTypeWillChange] public function offsetExists($offset) { return true; } /** * return the colour */ #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->colours[$offset % $this->count]; } #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->colours[$offset % $this->count] = $value; } #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new \Exception('Unexpected offsetUnset'); } }