【PHP7】コンストラクタインジェクションで差し替えたいときだけ差し替えれる書き方
忘れるわりに重要なのでメモ!
private $hogeService;
public function __construct(HogeService $hogeService = null)
{
$this->hogeService = $hogeService ?? new HogeService();
}
忘れるわりに重要なのでメモ!
private $hogeService;
public function __construct(HogeService $hogeService = null)
{
$this->hogeService = $hogeService ?? new HogeService();
}