X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/vendor/wikimedia/cdb/src/Reader/Hash.php diff --git a/vendor/wikimedia/cdb/src/Reader/Hash.php b/vendor/wikimedia/cdb/src/Reader/Hash.php new file mode 100644 index 00000000..36bbc3b6 --- /dev/null +++ b/vendor/wikimedia/cdb/src/Reader/Hash.php @@ -0,0 +1,114 @@ +data = $data; + } + + /** + * Close the file. Optional, you can just let the variable go out of scope. + */ + public function close() { + $this->data = array(); + $this->keys = null; + } + + /** + * Get a value with a given key. Only string values are supported. + * + * @param string $key + * + * @return bool|string The value associated with $key, or false if $key is not known. + */ + public function get( $key ) { + return isset( $this->data[ $key ] ) ? $this->data[ $key ] : false; + } + + /** + * Check whether key exists + * + * @param string $key + * + * @return bool + */ + public function exists( $key ) { + return isset( $this->data[ $key ] ); + } + + /** + * Fetch first key + * + * @return string + */ + public function firstkey() { + $this->keys = array_keys( $this->data ); + return $this->nextkey(); + } + + /** + * Fetch next key + * + * @return string + */ + public function nextkey() { + if ( $this->keys === null ) { + return $this->firstkey(); + } + + return empty( $this->keys ) ? false : array_shift( $this->keys ); + } + +}