I'm building a class that needs two arguments, and they can be passed through __constructor, or they can be set using setter methods.
What is the best way to check if arguments are passed through constructor?
I did it like this:
class Services {
public function __construct(array $configs, array $services)
{
if(isset($configs) AND isset($services)) {
$this->configs = $configs;
$this->services = $services;
}
}
public function setConfigs(array $configs)
{
$this->config = $configs;
}
public function setServices(array $services)
{
$this->services = $services;
}
}
Now this works fine, but I'm not 100% if this is the right way. The thing thats bothering me is that if arguments are passed through constructor, I want both of them there, not only one.
How would I prevent user to put only one argument in constructor?