/** * Tests getting and setting the type * @return void */ public function testName() { $plugin = new Plugin(); $plugin->setName('foo'); $this->assertEquals('foo', $plugin->getName()); $plugin = new Plugin(null, array('name' => 'bar')); $this->assertEquals('bar', $plugin->getName()); $this->setExpectedException('Nimbles\\Core\\Plugin\\Exception\\InvalidName'); $plugin->setName(123); }
/** * Factory method for creating plugins * @param string|int $index * @param string|array|\Nimbles\Core\Plugin $plugin * @return \Nimbles\Core\Plugin|null */ public static function factory($index, $plugin) { if (is_array($plugin)) { // treat as options $plugin = new Plugin($plugin); } else { if (!$plugin instanceof Plugin) { // empty plugin $plugin = new Plugin(); } } $plugin->setName($index); // name name and index in sync return $plugin; }