I want to write function in class. I want to run this function only if one variable is not set. I have 3 thoughts about this, but I do not know which one is best and looks "more professional".
1:
if (!isset($this->variable) {
$this->functionXxx();
}
2:
private function functionXxx()
{
if (!isset($this->variable)) {
//code here
}
}
3:
private function functionXxx()
{
if (isset($this->variable)) {
return;
}
//code here
}
First of all you should stop call methods function.
Second, if methodXxx returns something after operation you can use 3rd option, but if methodXxx is what we call void function (returns nothing) than you should use 2nd option.