data = $data; } /** * Close the file. Optional, you can just let the variable go out of scope. */ public function close(): void { $this->data = []; $this->keys = null; } /** * Get a value with a given key. Only string values are supported. * * @param string|int $key * @return string|false The value associated with $key, or false if $key is not known. */ public function get( $key ) { return $this->data[ $key ] ?? false; } /** * Check whether key exists * * @param string|int $key * @return bool */ public function exists( $key ): bool { return isset( $this->data[ $key ] ); } /** * Fetch first key * * @return string|false */ public function firstkey() { $this->keys = array_keys( $this->data ); return $this->nextkey(); } /** * Fetch next key * * @return string|false */ public function nextkey() { if ( $this->keys === null ) { return $this->firstkey(); } return $this->keys ? array_shift( $this->keys ) : false; } }