Factory $factory:
public function __construct(?Factory $factory = null) { $this->factory = $factory ?: new Factory(); }