$randomData */ public function __construct(array $randomData) { $this->randomData = $randomData; } /** * @param int $length * * @return string */ public function get($length) { if (!\array_key_exists($this->randomCount, $this->randomData)) { throw new RuntimeException('no more "random" data'); } return $this->randomData[$this->randomCount++]; } }