From 9a9c04512e5dcb77c7fe5d850e3f2a0250cc160e Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 18 Jan 2017 20:07:16 +0100 Subject: * Motor Sport Magazine feed provider --- lib/querypath/src/QueryPath/Options.php | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 lib/querypath/src/QueryPath/Options.php (limited to 'lib/querypath/src/QueryPath/Options.php') diff --git a/lib/querypath/src/QueryPath/Options.php b/lib/querypath/src/QueryPath/Options.php new file mode 100644 index 0000000..846984d --- /dev/null +++ b/lib/querypath/src/QueryPath/Options.php @@ -0,0 +1,84 @@ +Details + * This class defines no options of its own. Instead, it provides a + * central tool for developers to override options set by QueryPath. + * When a QueryPath object is created, it will evaluate options in the + * following order: + * + * - Options passed into qp() have highest priority. + * - Options in QueryPath::Options (this class) have the next highest priority. + * - If the option is not specified elsewhere, QueryPath will use its own defaults. + * + * @see qp() + * @see QueryPath::Options::set() + * @ingroup querypath_util + */ +class Options { + /** + * This is the static options array. + * + * Use the {@link set()}, {@link get()}, and {@link merge()} to + * modify this array. + */ + static $options = array(); + /** + * Set the default options. + * + * The passed-in array will be used as the default options list. + * + * @param array $array + * An associative array of options. + */ + static function set($array) { + self::$options = $array; + } + /** + * Get the default options. + * + * Get all options currently set as default. + * + * @return array + * An array of options. Note that only explicitly set options are + * returned. {@link QueryPath} defines default options which are not + * stored in this object. + */ + static function get() { + return self::$options; + } + /** + * Merge the provided array with existing options. + * + * On duplicate keys, the value in $array will overwrite the + * value stored in the options. + * + * @param array $array + * Associative array of options to merge into the existing options. + */ + static function merge($array) { + self::$options = $array + self::$options; + } + /** + * Returns true of the specified key is already overridden in this object. + * + * @param string $key + * The key to search for. + */ + static function has($key) { + return array_key_exists($key, self::$options); + } +} -- cgit v1.2.3