public function getInvoiceItemsByType($type)
{
return $this->invoiceItems->filter(function ($invoice) use ($type) {
/** @var InvoiceItem $invoice */
return $invoice->getType() == $type;
}
);
}
public function getInvoiceItemsByType($type) {
foreach ($this->invoiceItems as $invoice) {
if ($invoice->getType() == $type) {
return $invoice;
}
}
return null;
}
is there a difference between these two functions ? Someone told me that there is one but I can't manage to find what is it precisely and how one function instead of the other would affect my code