fieldName; switch ($fieldName) { case 'start': return $source->start; break; case 'end': return $source->end; break; case 'isPast': return $source->isPast; break; case 'isNotPast': return $source->isNotPast; break; case 'isFuture': return $source->isFuture; break; case 'isOnGoing': case 'isOngoing': return $source->isOngoing; break; default: return $source->$fieldName; break; } } }