1 回答

TA貢獻(xiàn)1844條經(jīng)驗(yàn) 獲得超8個(gè)贊
最小的例子:
class ApiClient
{
private RequestController $controller;
public function __construct(string $region)
{
$this->controller = new RequestController($region);
}
public function __call($methodName, $arguments)
{
// I'm skipping checks that class exists or anything else
// Also cause class names are case INsensitive you can just:
return new $methodName($this->controller);
// Or if case-sensitivity matters
$methodName = ucfirst($methodName);
return new $methodName($this->controller);
}
}
- 1 回答
- 0 關(guān)注
- 107 瀏覽
添加回答
舉報(bào)