/** * test creating singleton with instance name */ public function testCreateSingletonWithInstanceName() { $objectName = 'ClassKernel\\Data\\Object'; $testName = 'test_singleton'; /** @var \ClassKernel\Data\Object $objectOne */ $objectOne = Register::getSingleton($objectName, [], $testName); $converted = Register::name2code($objectName); $objectOne->setFirst(1); /** @var \ClassKernel\Data\Object $objectOne */ $objectTwo = Register::getSingleton($testName); $this->assertEquals(1, $objectTwo->getFirst()); $this->assertArrayHasKey($testName, Register::getRegisteredObjects()); $this->assertEquals(4, Register::getClassCounter()[$converted]); }
/** * save xml file, optionally will return as string * * @param string $url xml file path * @param boolean $asString if true return as string * @return string|boolean * * @example saveXmlFile('path/filename.xml'); save to file * @example saveXmlFile(false, true) will return as simple text */ public function saveXmlFile($url, $asString = false) { Register::tracer('save xml file', debug_backtrace(), '7E3A02'); $this->formatOutput = true; if ($url) { $bool = $this->save($url); if (!$bool) { $this->_error = 'save_file_error'; return false; } } if ($asString) { return $this->saveXML(); } return true; }