我有一个壁橱类,它的构造函数带有3个参数。
Class Closet
{
public function __construct($size, $length, Jeans $Jeans)
{
$this->size = $size;
$this->length = $length;
$this->Jeans = $Jeans;
}
}
我需要在某些地方使用依赖注入。
Class Outfit
{
public function __construct(Closet $Closet)
{
$this->Closet = $Closet;
}
public function pants($size, $length)
{
$this->Closet($size, $length);
}
}
所以我将它绑定在提供程序中
public function register()
{
$this->app->singleton(Closet::class, function ($app) {
return new Closet($app->make('Jeans'));
});
}
我应该怎么做才能将$ size,$ length绑定到寄存器中?