SqlParser\Context::load PHP Method

load() public static method

Contexts may be used by accessing the context directly.
public static load ( string $context = '' ) : void
$context string Name of the context or full class name that defines the context.
return void
    public static function load($context = '')
    {
        if (empty($context)) {
            $context = self::$defaultContext;
        }
        if ($context[0] !== '\\') {
            // Short context name (must be formatted into class name).
            $context = self::$contextPrefix . $context;
        }
        if (!class_exists($context)) {
            throw new \Exception('Specified context ("' . $context . '") does not exist.');
        }
        self::$loadedContext = $context;
        self::$KEYWORDS = $context::$KEYWORDS;
    }

Usage Example

Example #1
0
 /**
  * @expectedException Exception
  * @expectedExceptionMessage Specified context ("\SqlParser\Contexts\ContextFoo") does not exist.
  */
 public function testLoadError()
 {
     Context::load('Foo');
 }