php - Should an object being created by a factory method accept constructor arguments? -
i'm using factory pattern create users i'm having problem constructor issue.
i have following factory:
class userfactory { public function factorymethod(user $user_type) { $user = new $user_type($db); return $user; } }
i instantiate class follows:
$user = new userfactory(); $user = $user->factorymethod(new admin());
the issue is, need pass $db parameter new admin() call can't find way of doing or if it's possible.
have overlooked simple or not possible?
Comments
Post a Comment