Answer the question
In order to leave comments, you need to log in
What is the best way to pass methods to a function, in the form of objects or values?
So.
It is necessary to create an order on the site using the Market::createOrder() method.
Think about architecture. What is the best way to get parameters. As objects or values.
class Car extends ActiveRecord
{
protected $id;
protected $name;
}
class User extends ActiveRecord
{
protected $id;
protected $name;
}
class Market
{
public function createOrder(Car $Car, User $User)
{
// не нужно проверять существование в бд
// executing ...
}
// OR
public function createOrder($carId, $userId)
{
// нужно проверить на валидность
// executing ...
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question