Hey all,
Say you have a function that gets all all the invoices for a shop from a database, the invoice stores the customer id along with it.
function getAllInvoices()
{
//do magic...
return $invoicesArray;
}
That's straight forward enough, but what if instead of getting a customer id number you wanted to get the customer details so you add in the query to get the name from the number. Would you create a new function or add a new parameter to trigger getting the customer details?
Add Parameter:
function getAllInvoices($with_customer_details=false)
{
//do magic...
if($with_customer_details === true)
{
//more magic
}
return $invoicesArray;
}
New Function:
function getAllInvoicesWithCustomerDetails()
{
//do magic...
//more magic
return $invoicesArray;
}
What would you do?