public function testFormatting() { $this->assertEquals('TestController', Nano_Dispatcher::formatName('test', true)); $this->assertEquals('AnotherTestController', Nano_Dispatcher::formatName('another-test', true)); $this->assertEquals('Another_testController', Nano_Dispatcher::formatName('another_test', true)); $this->assertEquals('testAction', Nano_Dispatcher::formatName('test', false)); $this->assertEquals('anotherTestAction', Nano_Dispatcher::formatName('another-test', false)); $this->assertEquals('another_testAction', Nano_Dispatcher::formatName('another_test', false)); }
/** * @return string * @param string $action */ public function run($action) { $class = new ReflectionClass($this); $method = Nano_Dispatcher::formatName($action, false); $result = null; $this->runInit(); if (false !== $this->runBefore()) { try { $result = $this->{$method}(); } catch (Exception $e) { ErrorLog::append($e); throw $e; } } $this->runAfter(); if (false === $this->rendered) { return $this->render(null, null); } return $result; }