'Which of these line of code is "better,” and why?
First:
protected function isValid($orderIds)
{
......
$orderCount = Some Calculation... ;
return ( $orderCount == count($orderIds) );
}
Second:
protected function isValid($orderIds)
{
......
$orderCount = Some Calculation... ;
return ( $orderCount == count($orderIds) ) ? 1 : 0;
}
I am using this function like this
......
$isValid = $this->isValid($orderIds);
if($isValid) {
// do some thing here
}
Please look above written code. Is anything wrong, if I choose first function over second function?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
