/** * @test */ public function it_can_set_config_values() { $limelight = self::$limelight; $limelight->setConfig('test', 'Romaji', 'style'); $config = Config::getInstance(); $romaji = $config->get('Romaji'); $this->assertContains('test', $romaji); $config->resetConfig(); }
/** * Make decorator class from config value. * * @return RomajiConverter * @throws PluginErrorException */ private function makeStyleClass() { $config = Config::getInstance(); $options = $config->get('Romaji'); $style = $this->underscoreToCamelCase($options['style']); $styleClass = 'Limelight\\Plugins\\Library\\Romaji\\Styles\\' . ucfirst($style); if (class_exists($styleClass)) { return new $styleClass(); } throw new PluginErrorException("Style {$style} does not exist. Check config.php file."); }
/** * Run all registered plugins. * * @param string $text * @param Node|null $node * @param array|null $tokens * @param array|null $words * @param array $pluginWhiteList * * @return array */ protected function runPlugins($text, $node, $tokens, $words, $pluginWhiteList = []) { $pluginResults = []; $config = Config::getInstance(); $allPlugins = $config->getPlugins(); foreach ($allPlugins as $plugin => $namespace) { if ($this->isWhiteListed($plugin, $pluginWhiteList)) { $this->validatePlugin($namespace); $pluginClass = new $namespace($text, $node, $tokens, $words); $pluginResults[$plugin] = $this->firePlugin($pluginClass); } } return $pluginResults; }
/** * Build instance of Dispatcher. * * @return Limelight\Events\Dispatcher */ protected function buildDispatcher() { $config = Config::getInstance(); return new Dispatcher($config->get('listeners')); }
/** * Construct. * * @param string $message */ public function __construct($message = 'Requested plugin not found.') { $config = Config::getInstance(); $this->debug = $config->get('debug'); parent::__construct($message); }
/** * Dynamically set config values. Could be dangerous, be careful. * * @param string $value * @param string $key1 * @param string $key1 * * @return bool */ public function setConfig($value, $key1, $key2) { $config = Config::getInstance(); $config->set($value, $key1, $key2); }
/** * @test */ public function it_can_set_partOfSpeech() { Config::getInstance()->resetConfig(); $wordObject = $this->getResults()->pull(0); $partOfSpeech = $wordObject->partOfSpeech; $this->assertEquals('proper noun', $partOfSpeech); $wordObject->setPartOfSpeech('test'); $partOfSpeech = $wordObject->partOfSpeech; $this->assertEquals('test', $partOfSpeech); }
/** * Set static tokenizer on object. */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); $config = Config::getInstance(); self::$mecab = $config->make('Limelight\\Mecab\\Mecab'); }
/** * Reset config file. */ public static function tearDownAfterClass() { $config = Config::getInstance(); $config->resetConfig(); }
/** * @test */ public function it_can_be_instantiated() { $config = Config::getInstance(); $mecab = $config->make('Limelight\\Mecab\\Mecab'); $this->assertTrue(is_object($mecab), 'Mecab could not be instantiated.'); }
/** * Set user defined tags on object. */ private function setTags() { $config = Config::getInstance(); $tags = $config->get('Furigana'); foreach ($tags as $name => $tag) { $openClose = explode('{{}}', $tag); $this->tags[$name] = ['open' => isset($openClose[0]) ? $openClose[0] : '', 'close' => isset($openClose[1]) ? $openClose[1] : '']; } }
/** * @test * @expectedException Limelight\Exceptions\PluginNotFoundException * @expectedExceptionMessage Plugin data for Romaji can not be found. Is the Romaji plugin registered in config? */ public function it_throws_exception_when_plugin_not_registered() { $config = Config::getInstance(); $config->erase('plugins', 'Romaji'); $string = $this->getResults()->romaji(); $config->resetConfig(); }
/** * @test * @expectedException Limelight\Exceptions\InvalidInputException * @expectedExceptionMessage Key not found in config file. */ public function it_throws_exception_for_setting_invalid_config_value() { $config = Config::getInstance(); $config->set('test', 'sldkfj', 'lkfsd'); $config->resetConfig(); }