DataSift\Storyplayer\ConfigLib\HardCodedList::newConfig PHP Method

newConfig() public method

the returned object has already been added to our list, and does not need to be added manually
public newConfig ( string $name ) : object
$name string the name of this new config entry
return object
    public function newConfig($name)
    {
        // create our return object
        $classname = $this->configType;
        $obj = new $classname();
        $obj->setName($name);
        // add this to the list
        $this->addConfig($obj);
        return $obj;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @covers DataSift\Storyplayer\ConfigLib\ConfigList::__construct
  * @covers DataSift\Storyplayer\ConfigLib\ConfigList::addHardCodedList
  */
 public function testCanAddEntriesFromAHardCodedList()
 {
     // ----------------------------------------------------------------
     // setup your test
     $obj = new ConfigList("DataSift\\Storyplayer\\ConfigLib\\WrappedConfig", __DIR__ . '/ConfigListTestData1');
     $hardCodedList = new HardCodedList('DataSift\\Storyplayer\\ConfigLib\\WrappedConfig');
     $expected1 = $hardCodedList->newConfig('hard-coded-config-1');
     $expected1->getConfig()->name = 'config-1';
     $expected2 = $hardCodedList->newConfig('hard-coded-config-2');
     $expected2->getConfig()->name = 'config-2';
     // ----------------------------------------------------------------
     // perform the change
     $obj->addHardCodedList($hardCodedList);
     // ----------------------------------------------------------------
     // test the results
     $this->assertTrue($obj->hasEntry('hard-coded-config-1'));
     $this->assertSame($expected1, $obj->getEntry('hard-coded-config-1'));
     $this->assertTrue($obj->hasEntry('hard-coded-config-2'));
     $this->assertSame($expected2, $obj->getEntry('hard-coded-config-2'));
 }
All Usage Examples Of DataSift\Storyplayer\ConfigLib\HardCodedList::newConfig