folder = $folder; } /** * @param string $name The name of the action e.g. "Display", "List", or "Connectivity" */ public function create(string $name): ActionInterface { $name = strtolower($name) . 'Action'; $name = implode(array_map('ucfirst', explode('-', $name))); $filePath = $this->folder . $name . '.php'; if (!file_exists($filePath)) { throw new \Exception('Invalid action'); } $className = '\\' . $name; return new $className(); } }