for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SUC;
use InvalidArgumentException;
/**
* @license GNU GPL v2+
* @since 1.0
*
* @author mwjames
*/
class Options {
* @var array
private $options = array();
* @param array $options
public function __construct( array $options = array() ) {
$this->options = $options;
}
* @return self
public static function newFromGlobals() {
$GLOBALS['sucgCachePrefix'] = $GLOBALS['wgCachePrefix'] === false ? wfWikiID() : $GLOBALS['wgCachePrefix'];
$configuration = array(
'tooltipRequestCacheTTL' => $GLOBALS['sucgTooltipRequestCacheLifetime'],
'cachePrefix' => $GLOBALS['sucgCachePrefix'],
'enabledNamespaceWithTemplate' => $GLOBALS['sucgEnabledNamespaceWithTemplate'],
'enabledForAnonUsers' => $GLOBALS['sucgEnabledForAnonUser'],
'backendParserCacheLifetime' => $GLOBALS['sucgBackendParserCacheLifetime'],
'backendParserCacheType' => $GLOBALS['sucgBackendParserCacheType']
);
return new self( $configuration );
* @param string $key
* @param mixed $value
public function set( $key, $value ) {
$this->options[$key] = $value;
* @return boolean
public function has( $key ) {
return isset( $this->options[$key] ) || array_key_exists( $key, $this->options );
* @return string
* @throws InvalidArgumentException
public function get( $key ) {
if ( $this->has( $key ) ) {
return $this->options[$key];
throw new InvalidArgumentException( "{$key} is an unregistered option" );