I have two methods that are accessing data from an external object. Both methods do the same thing, up until accessing data (different data for each method).
public function GetObjectTitle(){
//some code identical to getObjectTitle() that finds correct codes to know which objects to access
$tempArray
foreach ($arrayOfObjects as $object)
{
if (!$object->getObjectMember()) {
$tempArray[] = "";
} else {
$tempArray[] = $this->Record->getRecordForIdp($object->getUser()->getId())->getTitle();
}
}
return $objects = $tempArray;
public function GetObjectDepartment(){
//some code identical to getObjectTitle() that finds correct codes to know which objects to access
$tempArray
foreach ($arrayOfObjects as $object)
{
if (!$object->getObjectMember()) {
$tempArray[] = "";
} else {
$tempArray[] = $this->Record->getRecordForIdp($object->getUser()->getId())->getDepartment();
}
}
return $objects = $tempArray;
The only difference is towards the end at the getDepartment
and getTitle
calls. I thought about passing in these two methods as variables but wonder if there is a better way.
Aucun commentaire:
Enregistrer un commentaire